Shopware Extensions
English
English
  • Shop Studio Docs
  • Extensions
    • Pixel Your Shop
      • Installation
      • Tracking
        • Google Analytics Tracking
        • Google Ads Tracking
        • Google Tag Manager
        • Facebook Tracking
        • Microsoft Advertising
        • Instagram Tracking
        • Pinterest Tracking
        • Hotjar Tracking
      • Cookie Consent
        • Shopware
        • Cookie Bot
      • Development
        • Debug
        • Change default events
      • Need help?
    • Resend order confirmation mail
      • Installation
      • Resend email
      • Need help?
    • Recipes
      • Installation
      • Setup
      • Create & publish recipes
      • Set up PDFs
      • Need help?
    • Blog/Magazine
      • Installation
      • Setup
      • Create & publish posts
      • Need help?
    • Advanced Search (Blog + Recipes)
      • Installation
      • Need help?
    • Hotjar
      • Installation
      • Setup
      • Need help?
    • Google Tag Manager
      • Installation
      • Setup
      • Events
      • Need help?
    • Personalized customer greeting
      • Installation
      • Setup
      • Change Snippets
      • Need help?
    • Google Ads
      • Installation
      • Setup
      • How to get Conversion ID and label
      • Dynamic remarketing setup
      • Conversions und events
      • Need help?
    • Back in stock notification
      • Installation
      • Setup
      • Common sources of errors
      • Need help?
    • Microsoft Advertising
      • Installation
      • Need Help?
    • Tree per order
      • Installation
      • Setup
        • TreeMates as provider
        • Custom provider
      • How it works
        • TreeMates as provider
        • Custom provider
      • Export
      • Common sources of error
      • Need help?
    • Health Check
      • Installation
      • Setup
      • Program additional checks
      • Need help?
    • Nutrition Labeling
      • Installation
      • Setup
      • Need help?
    • Product Mix Configurator
      • Installation
  • tracking
Powered by GitBook
On this page

Was this helpful?

  1. Extensions
  2. Health Check

Program additional checks

With a little bit of programming knowledge you also have the possibility to execute not yet supported health checks for other functions. For example the connection to Redis.

Database example

First you have to write a PHP class in your plugin that contains the logic. It is important that the interface `HealthCheckInterface` is implemented.

namespace ShopStudio\HealthCheck\Core\HealthCheck;

use Doctrine\DBAL\Connection;

class DatabaseHealthCheck implements HealthCheckInterface
{
    public const NAME = 'database';

    private Connection $connection;

    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }

    public function getName(): string
    {
        return self::NAME;
    }

    public function check(): ?HealthCheckResult
    {
        $up = true;

        try {
            $this->connection->executeQuery($this->connection->getDatabasePlatform()->getDummySelectSQL());
        } catch (\Throwable $throwable) {
            $up = false;
        }

        return new HealthCheckResult($up, ['additional' => 'payload']);
    }
}

Then implement the PHP class as a service in services.xml. Don't forget to tag the service as shop-studio.health-check.

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>

        <service id="ShopStudio\HealthCheck\Core\HealthCheck\DatabaseHealthCheck">
            <argument type="service" id="Doctrine\DBAL\Connection" />
            <tag name="shop-studio.health-check"/>
        </service>

    </services>
</container>
PreviousSetupNextNeed help?

Last updated 2 years ago

Was this helpful?