custom/plugins/OttMerchantShops/src/OttMerchantShops.php line 10

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Ott\MerchantShops;
  3. use Ott\Base\Bootstrap\CustomFieldService;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\System\CustomField\CustomFieldTypes;
  7. class OttMerchantShops extends Plugin
  8. {
  9.     public function install(InstallContext $installContext): void
  10.     {
  11.         $this->createCustomFields($installContext);
  12.     }
  13.     private function createCustomFields(InstallContext $installContext): void
  14.     {
  15.         $customFieldService $this->container->get(CustomFieldService::class);
  16.         $customFieldService->addFieldSet(
  17.             'merchant_shops',
  18.             [
  19.                 'de-DE' => 'Händlershops',
  20.                 'en-GB' => 'Merchant shops',
  21.             ],
  22.             [
  23.                 [
  24.                     'entityName' => 'category',
  25.                 ],
  26.             ]
  27.         );
  28.         $customFieldService->addField('merchant_shops', [
  29.             'name'   => 'merchant_id',
  30.             'type'   => CustomFieldTypes::SELECT,
  31.             'config' => [
  32.                 'entity'          => 'ott_merchant',
  33.                 'customFieldType' => 'entity',
  34.                 'componentName'   => 'sw-entity-single-select',
  35.                 'label'           => [
  36.                     'de-DE' => 'Händler',
  37.                     'en-GB' => 'Merchant',
  38.                 ],
  39.             ],
  40.         ]);
  41.         $customFieldService->update($installContext);
  42.     }
  43. }