<?php declare(strict_types=1);
namespace Ott\AutomatedPriceReduction;
use Ott\AutomatedPriceReduction\DependencyInjection\ImportProcessorCompilerPass;
use Ott\Base\Bootstrap\CustomFieldService;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\System\CustomField\CustomFieldTypes;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OttAutomatedPriceReduction extends Plugin
{
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new ImportProcessorCompilerPass());
parent::build($container);
}
public function install(InstallContext $context): void
{
$customFieldService = $this->container->get(CustomFieldService::class);
$customFieldService->addFieldSet(
'automated_price_reduction',
[
'de-DE' => 'Preisreduzierung',
'en-GB' => 'Price reduction',
],
[
[
'entityName' => 'product',
],
]
);
$customFieldService->addField('automated_price_reduction', [
'name' => 'price_history',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'de-DE' => 'Produkt Preisreduktions Historie',
'en-GB' => 'Product price reduction history',
],
],
]);
$customFieldService->update($context);
}
public function activate(ActivateContext $context): void
{
}
public function deactivate(DeactivateContext $context): void
{
}
}