custom/plugins/OttAutomatedPriceReduction/src/OttAutomatedPriceReduction.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Ott\AutomatedPriceReduction;
  3. use Ott\AutomatedPriceReduction\DependencyInjection\ImportProcessorCompilerPass;
  4. use Ott\Base\Bootstrap\CustomFieldService;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  8. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  9. use Shopware\Core\System\CustomField\CustomFieldTypes;
  10. use Symfony\Component\DependencyInjection\ContainerBuilder;
  11. class OttAutomatedPriceReduction extends Plugin
  12. {
  13.     public function build(ContainerBuilder $container): void
  14.     {
  15.         $container->addCompilerPass(new ImportProcessorCompilerPass());
  16.         parent::build($container);
  17.     }
  18.     public function install(InstallContext $context): void
  19.     {
  20.         $customFieldService $this->container->get(CustomFieldService::class);
  21.         $customFieldService->addFieldSet(
  22.             'automated_price_reduction',
  23.             [
  24.                 'de-DE' => 'Preisreduzierung',
  25.                 'en-GB' => 'Price reduction',
  26.             ],
  27.             [
  28.                 [
  29.                     'entityName' => 'product',
  30.                 ],
  31.             ]
  32.         );
  33.         $customFieldService->addField('automated_price_reduction', [
  34.             'name'   => 'price_history',
  35.             'type'   => CustomFieldTypes::TEXT,
  36.             'config' => [
  37.                 'label'           => [
  38.                     'de-DE' => 'Produkt Preisreduktions Historie',
  39.                     'en-GB' => 'Product price reduction history',
  40.                 ],
  41.             ],
  42.         ]);
  43.         $customFieldService->update($context);
  44.     }
  45.     public function activate(ActivateContext $context): void
  46.     {
  47.     }
  48.     public function deactivate(DeactivateContext $context): void
  49.     {
  50.     }
  51. }