<?php declare(strict_types=1);
namespace Acris\SuggestedProducts;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
class AcrisSuggestedProductsCS extends Plugin
{
public function uninstall(UninstallContext $context): void
{
if ($context->keepUserData()) {
return;
}
$this->cleanupDatabase();
}
public function update(UpdateContext $updateContext): void
{
$this->resetEnableConfigs();
}
private function cleanupDatabase(): void
{
$connection = $this->container->get(Connection::class);
$connection->executeStatement('DROP TABLE IF EXISTS acris_customers_also_viewed');
}
private function resetEnableConfigs(): void
{
$systemConfigService = $this->container->get('Shopware\Core\System\SystemConfig\SystemConfigService');
$systemConfigService->set('AcrisSuggestedProductsCS.config.enableRecentlyViewedItems', false);
$systemConfigService->set('AcrisSuggestedProductsCS.config.enableCustomersAlsoBought', false);
$systemConfigService->set('AcrisSuggestedProductsCS.config.enableCustomersAlsoViewed', false);
}
}