<?php declare(strict_types=1);
namespace LenzPlatformClp;
use Doctrine\DBAL\Connection;
use Exception;
use LenzPlatformClp\Core\Content\Clp\Service\ClpImportService;
use LenzPlatformClp\Core\Content\Clp\Service\ClpService;
use LenzPlatformClp\Core\Content\Clp\Service\Importer\CsvImporter;
use LenzPlatformClp\Core\Content\Clp\Service\UpdateClpStrategy;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class LenzPlatformClp extends Plugin
{
public function activate(Plugin\Context\ActivateContext $activateContext): void
{
/** @var ClpImportService $clpService */
$clpImportService = $this->container->get(ClpImportService::class);
$clpImportService->import();
}
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if (!$context->keepUserData()) {
$connection = $this->container->get(Connection::class);
try {
// Drop binary column for the variants
$connection->executeStatement('ALTER TABLE `product` DROP COLUMN `lenzPlatformClp`');
} catch(Exception $e) {
echo "Column \"clp\" on \"product\" not deleted.\n\r";
}
$tablesToDelete = [
'lenz_platform_clp_product',
'lenz_platform_clp_translation',
'lenz_platform_clp',
];
foreach ($tablesToDelete as $table) {
try {
$connection->executeStatement('DROP TABLE IF EXISTS `' . $table . '`');
} catch(Exception $e) {
echo "Table \"" . $table . "\" not deleted.\n\r";
}
}
}
}
}