<?php declare(strict_types=1);
namespace MadProductVisibility;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class MadProductVisibility extends Plugin
{
public function activate(ActivateContext $activateContext): void
{
$registry = $this->container->get(EntityIndexerRegistry::class);
$registry->sendIndexingMessage(['product.indexer']);
}
public function uninstall(UninstallContext $uninstallContext): void
{
parent::uninstall($uninstallContext);
if ($uninstallContext->keepUserData()) {
return;
}
$connection = $this->container->get(Connection::class);
$connection->executeUpdate('DROP TABLE IF EXISTS `mad_product_role_blacklist`');
$connection->executeUpdate('ALTER TABLE `product` DROP COLUMN `madProductRoleBlacklist`');
}
}