<?php declare(strict_types=1);
namespace CustomFieldFilter;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Doctrine\DBAL\Connection;
class CustomFieldFilter extends Plugin
{
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$connection = $this->container->get(Connection::class);
$connection->executeStatement("
CREATE TABLE IF NOT EXISTS `as_custom_fields_filter`
(
`id` BINARY(16) NOT NULL,
`custom_field_id` BINARY(16) NOT NULL,
`type` VARCHAR(255) NOT NULL,
`display_name` VARCHAR(255) NOT NULL,
`request_parameter` VARCHAR(255) NOT NULL,
`active` TINYINT(1) NULL DEFAULT '0',
`position` INT(11) NULL DEFAULT '0',
`created_at` DATETIME(3) NOT NULL,
`updated_at` DATETIME(3) NULL,
PRIMARY KEY (`id`),
KEY `fk.custom_fields_filter.custom_field_id` (`custom_field_id`),
CONSTRAINT `fk.custom_fields_filter.custom_field_id` FOREIGN KEY (`custom_field_id`) REFERENCES `custom_field` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
");
}
public function uninstall(UninstallContext $uninstallContext): void
{
$connection = $this->container->get(Connection::class);
$connection->executeStatement("DROP TABLE IF EXISTS `as_custom_fields_filter`");
}
}