vendor/store.shopware.com/lenzplatformclp/src/LenzPlatformClp.php line 22

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace LenzPlatformClp;
  3. use Doctrine\DBAL\Connection;
  4. use Exception;
  5. use LenzPlatformClp\Core\Content\Clp\Service\ClpImportService;
  6. use LenzPlatformClp\Core\Content\Clp\Service\ClpService;
  7. use LenzPlatformClp\Core\Content\Clp\Service\Importer\CsvImporter;
  8. use LenzPlatformClp\Core\Content\Clp\Service\UpdateClpStrategy;
  9. use Shopware\Core\Framework\Context;
  10. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  11. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  12. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  13. use Shopware\Core\Framework\Plugin;
  14. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  15. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  16. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  17. use Shopware\Core\System\CustomField\Aggregate\CustomFieldSet\CustomFieldSetEntity;
  18. use Shopware\Core\System\CustomField\CustomFieldTypes;
  19. class LenzPlatformClp extends Plugin
  20. {
  21.     public function install(InstallContext $installContext): void
  22.     {
  23.         $this->createOrUpdateCustomFields('lenz_platform_clp_product');
  24.     }
  25.     public function activate(Plugin\Context\ActivateContext $activateContext): void
  26.     {
  27.         /** @var ClpImportService $clpService */
  28.         $clpImportService $this->container->get(ClpImportService::class);
  29.         $clpImportService->import();
  30.     }
  31.     public function update(UpdateContext $updateContext): void
  32.     {
  33.         $this->createOrUpdateCustomFields('lenz_platform_clp_product');
  34.     }
  35.     public function postUpdate(UpdateContext $updateContext): void
  36.     {
  37.         if($this->container->has(ClpImportService::class)) {
  38.             /** @var ClpImportService $clpService */
  39.             $clpImportService $this->container->get(ClpImportService::class);
  40.             $clpImportService->import();
  41.         }
  42.     }
  43.     public function uninstall(UninstallContext $context): void
  44.     {
  45.         parent::uninstall($context);
  46.         if (!$context->keepUserData()) {
  47.             $connection $this->container->get(Connection::class);
  48.             try {
  49.                 // Drop binary column for the variants
  50.                 $connection->executeStatement('ALTER TABLE `product` DROP COLUMN `lenzPlatformClp`');
  51.             } catch(Exception $e) {
  52.                 echo "Column \"clp\" on \"product\" not deleted.\n\r";
  53.             }
  54.             $tablesToDelete = [
  55.                 'lenz_platform_clp_product',
  56.                 'lenz_platform_clp_translation',
  57.                 'lenz_platform_clp',
  58.             ];
  59.             foreach ($tablesToDelete as $table) {
  60.                 try {
  61.                     $connection->executeStatement('DROP TABLE IF EXISTS `' $table '`');
  62.                 } catch(Exception $e) {
  63.                     echo "Table \"" $table "\" not deleted.\n\r";
  64.                 }
  65.             }
  66.             $this->deleteCustomFieldSet('lenz_platform_clp_product');
  67.         }
  68.     }
  69.     // -- Custom fields
  70.     private array $customFieldSets = [
  71.         'lenz_platform_clp_product' => [
  72.             'name' => 'lenz_platform_clp_product',
  73.             'config' => [
  74.                 'label' => [
  75.                     'en-GB' => 'CLP/REACH - Product',
  76.                     'de-DE' => 'CLP/REACH - Produkt',
  77.                 ],
  78.             ],
  79.             'relations' => [
  80.                 ['entityName' => 'product']
  81.             ],
  82.             'customFields' => [
  83.                 [
  84.                     'name' => 'lenz_platform_clp_product_euh208_var1',
  85.                     'type' => CustomFieldTypes::TEXT,
  86.                     'config' => [
  87.                         'label' => [
  88.                             'en-GB' => 'EUH208 - Contains <name of sensitising substance>. May produce an allergic reaction.',
  89.                             'de-DE' => 'EUH208 - Enthält <Name des sensibilisierenden Stoffes>. Kann allergische Reaktionen hervorrufen.',
  90.                             'fr-FR' => 'EUH208 - Contient <nom de la substance sensibilisante>. Peut produire une réaction allergique.',
  91.                         ],
  92.                         'customFieldPosition' => 101,
  93.                     ],
  94.                 ],
  95.                 [
  96.                     'name' => 'lenz_platform_clp_product_h340_var1',
  97.                     'type' => CustomFieldTypes::TEXT,
  98.                     'config' => [
  99.                         'label' => [
  100.                             'en-GB' => 'H340 - May cause genetic defects <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  101.                             'de-DE' => 'H340 - Kann genetische Defekte verursachen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  102.                             'fr-FR' => 'H340 - Peut induire des anomalies génétiques <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>.',
  103.                         ],
  104.                         'customFieldPosition' => 102,
  105.                     ],
  106.                 ],
  107.                 [
  108.                     'name' => 'lenz_platform_clp_product_h341_var1',
  109.                     'type' => CustomFieldTypes::TEXT,
  110.                     'config' => [
  111.                         'label' => [
  112.                             'en-GB' => 'H341 - Suspected of causing genetic defects <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  113.                             'de-DE' => 'H341 - Kann vermutlich genetische Defekte verursachen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  114.                             'fr-FR' => 'H341 - Susceptible d\'induire des anomalies génétiques <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  115.                         ],
  116.                         'customFieldPosition' => 103,
  117.                     ],
  118.                 ],
  119.                 [
  120.                     'name' => 'lenz_platform_clp_product_h350_var1',
  121.                     'type' => CustomFieldTypes::TEXT,
  122.                     'config' => [
  123.                         'label' => [
  124.                             'en-GB' => 'H350 - May cause cancer <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  125.                             'de-DE' => 'H350 - Kann Krebs erzeugen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  126.                             'fr-FR' => 'H350 - Peut provoquer le cancer <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  127.                         ],
  128.                         'customFieldPosition' => 104,
  129.                     ],
  130.                 ],
  131.                 [
  132.                     'name' => 'lenz_platform_clp_product_h351_var1',
  133.                     'type' => CustomFieldTypes::TEXT,
  134.                     'config' => [
  135.                         'label' => [
  136.                             'en-GB' => 'H351 - Suspected of causing cancer <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  137.                             'de-DE' => 'H351 - Kann vermutlich Krebs erzeugen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  138.                             'fr-FR' => 'H351 - Susceptible de provoquer le cancer <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  139.                         ],
  140.                         'customFieldPosition' => 105,
  141.                     ],
  142.                 ],
  143.                 [
  144.                     'name' => 'lenz_platform_clp_product_h360_var1',
  145.                     'type' => CustomFieldTypes::TEXT,
  146.                     'config' => [
  147.                         'label' => [
  148.                             'en-GB' => 'H360 VAR1 - May damage fertility or the unborn child <state specific effect if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  149.                             'de-DE' => 'H360 VAR1 - Kann die Fruchtbarkeit beeinträchtigen oder das Kind im Mutterleib schädigen <konkrete Wirkung angeben, sofern bekannt> <Expositionsweg angeben, sofern schlüssig belegt ist, dass die Gefahr bei keinem anderen Expositionsweg besteht>',
  150.                             'fr-FR' => 'H360 VAR1 - Peut nuire à la fertilité ou au fœtus <indiquer l\'effet s\'il est connu> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  151.                         ],
  152.                         'customFieldPosition' => 106,
  153.                     ],
  154.                 ],
  155.                 [
  156.                     'name' => 'lenz_platform_clp_product_h360_var2',
  157.                     'type' => CustomFieldTypes::TEXT,
  158.                     'config' => [
  159.                         'label' => [
  160.                             'en-GB' => 'H360 VAR2 - May damage fertility or the unborn child <state specific effect if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  161.                             'de-DE' => 'H360 VAR2 - Kann die Fruchtbarkeit beeinträchtigen oder das Kind im Mutterleib schädigen <konkrete Wirkung angeben, sofern bekannt> <Expositionsweg angeben, sofern schlüssig belegt ist, dass die Gefahr bei keinem anderen Expositionsweg besteht>',
  162.                             'fr-FR' => 'H360 VAR2 - Peut nuire à la fertilité ou au fœtus <indiquer l\'effet s\'il est connu> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  163.                         ],
  164.                         'customFieldPosition' => 107,
  165.                     ],
  166.                 ],
  167.                 [
  168.                     'name' => 'lenz_platform_clp_product_h361_var1',
  169.                     'type' => CustomFieldTypes::TEXT,
  170.                     'config' => [
  171.                         'label' => [
  172.                             'en-GB' => 'H361 VAR1 - Suspected of damaging fertility or the unborn child <state specific effect if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  173.                             'de-DE' => 'H361 VAR1 - Kann vermutlich die Fruchtbarkeit beeinträchtigen oder das Kind im Mutterleib schädigen <konkrete Wirkung angeben, sofern bekannt>',
  174.                             'fr-FR' => 'H361 VAR1 - Susceptible de nuire à la fertilité ou au fœtus <indiquer l\'effet s\'il est connu> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  175.                         ],
  176.                         'customFieldPosition' => 108,
  177.                     ],
  178.                 ],
  179.                 [
  180.                     'name' => 'lenz_platform_clp_product_h361_var2',
  181.                     'type' => CustomFieldTypes::TEXT,
  182.                     'config' => [
  183.                         'label' => [
  184.                             'en-GB' => 'H361 VAR2 - Suspected of damaging fertility or the unborn child <state specific effect if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  185.                             'fr-FR' => 'H361 VAR2 - Susceptible de nuire à la fertilité ou au fœtus <indiquer l\'effet s\'il est connu> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  186.                         ],
  187.                         'customFieldPosition' => 109,
  188.                     ],
  189.                 ],
  190.                 [
  191.                     'name' => 'lenz_platform_clp_product_h370_var1',
  192.                     'type' => CustomFieldTypes::TEXT,
  193.                     'config' => [
  194.                         'label' => [
  195.                             'en-GB' => 'H370 VAR1 - Causes damage to organs <or state all organs affected, if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  196.                             'de-DE' => 'H370 VAR1 - Schädigt die Organe <oder alle betroffenen Organe nennen, sofern bekannt> <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  197.                             'fr-FR' => 'H370 VAR1 - Risque avéré d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  198.                         ],
  199.                         'customFieldPosition' => 110,
  200.                     ],
  201.                 ],
  202.                 [
  203.                     'name' => 'lenz_platform_clp_product_h370_var2',
  204.                     'type' => CustomFieldTypes::TEXT,
  205.                     'config' => [
  206.                         'label' => [
  207.                             'en-GB' => 'H370 VAR2 - Causes damage to organs <or state all organs affected, if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  208.                             'de-DE' => 'H370 VAR2 - Schädigt die Organe <oder alle betroffenen Organe nennen, sofern bekannt> <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  209.                             'fr-FR' => 'H370 VAR2 - Risque avéré d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  210.                         ],
  211.                         'customFieldPosition' => 111,
  212.                     ],
  213.                 ],
  214.                 [
  215.                     'name' => 'lenz_platform_clp_product_h371_var1',
  216.                     'type' => CustomFieldTypes::TEXT,
  217.                     'config' => [
  218.                         'label' => [
  219.                             'en-GB' => 'H371 VAR1 - May cause damage to organs <or state all organs affected, if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  220.                             'de-DE' => 'H371 VAR1 - Kann die Organe schädigen <oder alle betroffenen Organe nennen, sofern bekann> <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  221.                             'fr-FR' => 'H371 VAR1 - Risque présumé d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  222.                         ],
  223.                         'customFieldPosition' => 112,
  224.                     ],
  225.                 ],
  226.                 [
  227.                     'name' => 'lenz_platform_clp_product_h371_var2',
  228.                     'type' => CustomFieldTypes::TEXT,
  229.                     'config' => [
  230.                         'label' => [
  231.                             'en-GB' => 'H371 VAR2 - May cause damage to organs <or state all organs affected, if known> <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  232.                             'de-DE' => 'H371 VAR2 - Kann die Organe schädigen <oder alle betroffenen Organe nennen, sofern bekann> <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  233.                             'fr-FR' => 'H371 VAR2 - Risque présumé d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  234.                         ],
  235.                         'customFieldPosition' => 113,
  236.                     ],
  237.                 ],
  238.                 [
  239.                     'name' => 'lenz_platform_clp_product_h372_var1',
  240.                     'type' => CustomFieldTypes::TEXT,
  241.                     'config' => [
  242.                         'label' => [
  243.                             'en-GB' => 'H372 VAR1 - Causes damage to organs <state all organs affected, if known> through prolonged or repeated exposure <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  244.                             'de-DE' => 'H372 VAR1 - Schädigt die Organe <alle betroffenen Organe nennen> bei längerer oder wiederholter Exposition <Expositionsweg angeben, wenn schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  245.                             'fr-FR' => 'H372 VAR1 - Risque présumé d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  246.                         ],
  247.                         'customFieldPosition' => 114,
  248.                     ],
  249.                 ],
  250.                 [
  251.                     'name' => 'lenz_platform_clp_product_h372_var2',
  252.                     'type' => CustomFieldTypes::TEXT,
  253.                     'config' => [
  254.                         'label' => [
  255.                             'en-GB' => 'H372 VAR2 - Causes damage to organs <state all organs affected, if known> through prolonged or repeated exposure <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  256.                             'de-DE' => 'H372 VAR2 - Schädigt die Organe <alle betroffenen Organe nennen> bei längerer oder wiederholter Exposition <Expositionsweg angeben, wenn schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  257.                             'fr-FR' => 'H372 VAR2 - Risque présumé d\'effets graves pour les organes <ou indiquer tous les organes affectés, s\'ils sont connus> <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  258.                         ],
  259.                         'customFieldPosition' => 115,
  260.                     ],
  261.                 ],
  262.                 [
  263.                     'name' => 'lenz_platform_clp_product_h373_var1',
  264.                     'type' => CustomFieldTypes::TEXT,
  265.                     'config' => [
  266.                         'label' => [
  267.                             'en-GB' => 'H373 VAR1 - May cause damage to organs <state all organs affected, if known> through prolonged or repeated exposure <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  268.                             'de-DE' => 'H373 VAR1 - Kann die Organe schädigen <alle betroffenen Organe nennen, sofern bekannt> bei längerer oder wiederholter Exposition <Expositionsweg angeben, wenn schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  269.                             'fr-FR' => 'H373 VAR1 - Risque présumé d\'effets graves pour les organes <indiquer tous les organes affectés, s\'ils sont connus> à la suite d\'expositions répétées ou d\'une exposition prolongée <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  270.                         ],
  271.                         'customFieldPosition' => 116,
  272.                     ],
  273.                 ],
  274.                 [
  275.                     'name' => 'lenz_platform_clp_product_h373_var2',
  276.                     'type' => CustomFieldTypes::TEXT,
  277.                     'config' => [
  278.                         'label' => [
  279.                             'en-GB' => 'H373 VAR2 - May cause damage to organs <state all organs affected, if known> through prolonged or repeated exposure <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
  280.                             'de-DE' => 'H373 VAR2 - Kann die Organe schädigen <alle betroffenen Organe nennen, sofern bekannt> bei längerer oder wiederholter Exposition <Expositionsweg angeben, wenn schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
  281.                             'fr-FR' => 'H373 VAR2 - Risque présumé d\'effets graves pour les organes <indiquer tous les organes affectés, s\'ils sont connus> à la suite d\'expositions répétées ou d\'une exposition prolongée <indiquer la voie d\'exposition s\'il est formellement prouvé qu\'aucune autre voie d\'exposition ne conduit au même danger>',
  282.                         ],
  283.                         'customFieldPosition' => 117,
  284.                     ],
  285.                 ],
  286.                 [
  287.                     'name' => 'lenz_platform_clp_product_p221_var1',
  288.                     'type' => CustomFieldTypes::TEXT,
  289.                     'config' => [
  290.                         'label' => [
  291.                             'en-GB' => 'P221 - Take any precaution to avoid mixing with combustibles <...>',
  292.                             'de-DE' => 'P221 - Mischen mit brennbaren Stoffen/<...> unbedingt verhindern.',
  293.                             'fr-FR' => 'P221 - Prendre toutes précautions pour éviter de mélanger avec des matières combustibles <...>',
  294.                         ],
  295.                         'customFieldPosition' => 118,
  296.                     ],
  297.                 ],
  298.                 [
  299.                     'name' => 'lenz_platform_clp_product_p230_var1',
  300.                     'type' => CustomFieldTypes::TEXT,
  301.                     'config' => [
  302.                         'label' => [
  303.                             'en-GB' => 'P230 - Keep wetted with <...>',
  304.                             'de-DE' => 'P230 - Feucht halten mit <...>',
  305.                             'fr-FR' => 'P230 - Maintenir humidifié avec <...>',
  306.                         ],
  307.                         'customFieldPosition' => 119,
  308.                     ],
  309.                 ],
  310.                 [
  311.                     'name' => 'lenz_platform_clp_product_p231_var1',
  312.                     'type' => CustomFieldTypes::TEXT,
  313.                     'config' => [
  314.                         'label' => [
  315.                             'en-GB' => 'P231 - Handle and store contents under inert gas/<...>',
  316.                             'de-DE' => 'P231 - Inhalt unter inertem Gas/<…> handhaben und aufbewahren.',
  317.                             'fr-FR' => 'P231 - Manipuler et stocker le contenu sous gaz inerte/<…>',
  318.                         ],
  319.                         'customFieldPosition' => 120,
  320.                     ],
  321.                 ],
  322.                 [
  323.                     'name' => 'lenz_platform_clp_product_p231_p232_var1',
  324.                     'type' => CustomFieldTypes::TEXT,
  325.                     'config' => [
  326.                         'label' => [
  327.                             'en-GB' => 'P231 + P232 - Handle and store contents under inert gas/<…>. Protect from moisture.',
  328.                             'de-DE' => 'P231 + P232 - Inhalt unter inertem Gas/<…> handhaben und aufbewahren. Vor Feuchtigkeit schützen.',
  329.                             'fr-FR' => 'P231 + P232 - Manipuler et stocker le contenu sous gaz inerte/<…> Protéger de l\'humidité.',
  330.                         ],
  331.                         'customFieldPosition' => 121,
  332.                     ],
  333.                 ],
  334.                 [
  335.                     'name' => 'lenz_platform_clp_product_p241_var1',
  336.                     'type' => CustomFieldTypes::TEXT,
  337.                     'config' => [
  338.                         'label' => [
  339.                             'en-GB' => 'P241 - Use explosion-proof [electrical/ventilating/lighting/<…>] equipment.',
  340.                             'de-DE' => 'P241 - Explosionsgeschützte elektrische Geräte/Lüftungsanlagen/Beleuchtungsanlagen/<...> verwenden.',
  341.                             'fr-FR' => 'P241 - Utiliser du matériel [électrique/de ventilation/d\'éclairage/<…>] antidéflagrant.',
  342.                         ],
  343.                         'customFieldPosition' => 122,
  344.                     ],
  345.                 ],
  346.                 [
  347.                     'name' => 'lenz_platform_clp_product_p250_var1',
  348.                     'type' => CustomFieldTypes::TEXT,
  349.                     'config' => [
  350.                         'label' => [
  351.                             'en-GB' => 'P250 - Do not subject to grinding/shock/friction/<…>.',
  352.                             'de-DE' => 'P250 - Nicht schleifen/stoßen/reiben/<…>.',
  353.                             'fr-FR' => 'P250 - Éviter les abrasions/les chocs/les frottements/<…>.',
  354.                         ],
  355.                         'customFieldPosition' => 123,
  356.                     ],
  357.                 ],
  358.                 [
  359.                     'name' => 'lenz_platform_clp_product_p264_var1',
  360.                     'type' => CustomFieldTypes::TEXT,
  361.                     'config' => [
  362.                         'label' => [
  363.                             'en-GB' => 'P264 - Wash <...> thoroughly after handling.',
  364.                             'de-DE' => 'P264 - Nach Gebrauch <...> gründlich waschen.',
  365.                             'fr-FR' => 'P264 - Se laver <...> soigneusement après manipulation.',
  366.                         ],
  367.                         'customFieldPosition' => 124,
  368.                     ],
  369.                 ],
  370.                 [
  371.                     'name' => 'lenz_platform_clp_product_p280_var1',
  372.                     'type' => CustomFieldTypes::TEXT,
  373.                     'config' => [
  374.                         'label' => [
  375.                             'en-GB' => 'P280 - Wear protective gloves/protective clothing/eye protection/face protection/hearing protection/<...>',
  376.                             'de-DE' => 'P280 - Schutzhandschuhe/ Schutzkleidung/Augenschutz/ Gesichtsschutz/Gehörschutz/<…> tragen',
  377.                             'fr-FR' => 'P280 - Porter des gants de protection/des vêtements de protection/un équipement de protection des yeux/du visage/une protection auditive/ <...>',
  378.                         ],
  379.                         'customFieldPosition' => 125,
  380.                     ],
  381.                 ],
  382.                 [
  383.                     'name' => 'lenz_platform_clp_product_p301_p310_var1',
  384.                     'type' => CustomFieldTypes::TEXT,
  385.                     'config' => [
  386.                         'label' => [
  387.                             'en-GB' => 'P301 + P310 - IF SWALLOWED:  Immediately call a POISON CENTER/doctor/<…>',
  388.                             'de-DE' => 'P301 + P310 - BEI VERSCHLUCKEN: Sofort GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
  389.                             'fr-FR' => 'P301 + P310 - EN CAS D\'INGESTION: Appeler immédiatement un CENTRE ANTIPOISON/un médecin/<…>',
  390.                         ],
  391.                         'customFieldPosition' => 126,
  392.                     ],
  393.                 ],
  394.                 [
  395.                     'name' => 'lenz_platform_clp_product_p301_p312_var1',
  396.                     'type' => CustomFieldTypes::TEXT,
  397.                     'config' => [
  398.                         'label' => [
  399.                             'en-GB' => 'P301 + P312 - Call a POISON CENTRE/doctor/<…> if you feel unwell.',
  400.                             'de-DE' => 'P301 + P312 - BEI VERSCHLUCKEN: Bei Unwohlsein GIFTINFORMATIONSZENTRUM/Arzt/<…> anrufen.',
  401.                             'fr-FR' => 'P301 + P312 - EN CAS D\'INGESTION: Appeler un CENTRE ANTIPOISON/un médecin/<…>/ en cas de malaise.',
  402.                         ],
  403.                         'customFieldPosition' => 127,
  404.                     ],
  405.                 ],
  406.                 [
  407.                     'name' => 'lenz_platform_clp_product_p302_p352_var1',
  408.                     'type' => CustomFieldTypes::TEXT,
  409.                     'config' => [
  410.                         'label' => [
  411.                             'en-GB' => 'P302 + P312 - Wash with plenty of water/<...>',
  412.                             'de-DE' => 'P302 + P312 - BERÜHRUNG MIT DER HAUT: Mit viel Wasser/<…>/waschen.',
  413.                             'fr-FR' => 'P302 + P312 - EN CAS DE CONTACT AVEC LA PEAU: Laver abondamment à l\'eau/<...>',
  414.                         ],
  415.                         'customFieldPosition' => 128,
  416.                     ],
  417.                 ],
  418.                 [
  419.                     'name' => 'lenz_platform_clp_product_p308_p311_var1',
  420.                     'type' => CustomFieldTypes::TEXT,
  421.                     'config' => [
  422.                         'label' => [
  423.                             'en-GB' => 'P308 + P311 - IF exposed or concerned:  Call a POISON CENTER/doctor/<...>',
  424.                             'de-DE' => 'P308 + P311 - BEI Exposition oder falls betroffen: GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
  425.                             'fr-FR' => 'P308 + P311 - EN CAS d\'exposition prouvée ou suspectée: Appeler un CENTRE ANTIPOISON/un médecin/<...>',
  426.                         ],
  427.                         'customFieldPosition' => 129,
  428.                     ],
  429.                 ],
  430.                 [
  431.                     'name' => 'lenz_platform_clp_product_p310_var1',
  432.                     'type' => CustomFieldTypes::TEXT,
  433.                     'config' => [
  434.                         'label' => [
  435.                             'en-GB' => 'P310 - Immediately call a POISON CENTER/doctor/<…>',
  436.                             'de-DE' => 'P310 - Sofort GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
  437.                             'fr-FR' => 'P310 - Appeler immédiatement un CENTRE ANTIPOISON/un médecin/<...>',
  438.                         ],
  439.                         'customFieldPosition' => 130,
  440.                     ],
  441.                 ],
  442.                 [
  443.                     'name' => 'lenz_platform_clp_product_p311_var1',
  444.                     'type' => CustomFieldTypes::TEXT,
  445.                     'config' => [
  446.                         'label' => [
  447.                             'en-GB' => 'P311 - Call a POISON CENTER/doctor/<…>',
  448.                             'de-DE' => 'P311 - GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
  449.                             'fr-FR' => 'P311 - Appeler un CENTRE ANTIPOISON/un médecin<...>',
  450.                         ],
  451.                         'customFieldPosition' => 131,
  452.                     ],
  453.                 ],
  454.                 [
  455.                     'name' => 'lenz_platform_clp_product_p312_var1',
  456.                     'type' => CustomFieldTypes::TEXT,
  457.                     'config' => [
  458.                         'label' => [
  459.                             'en-GB' => 'P312 - Call a POISON CENTRE/doctor/<…> if you feel unwell.',
  460.                             'de-DE' => 'P312 - Bei Unwohlsein GIFTINFORMATIONSZENTRUM/Arzt/<…> anrufen.',
  461.                             'fr-FR' => 'P312 - Appeler un CENTRE ANTIPOISON/un médecin/<…> en cas de malaise',
  462.                         ],
  463.                         'customFieldPosition' => 132,
  464.                     ],
  465.                 ],
  466.                 [
  467.                     'name' => 'lenz_platform_clp_product_p320_var1',
  468.                     'type' => CustomFieldTypes::TEXT,
  469.                     'config' => [
  470.                         'label' => [
  471.                             'en-GB' => 'P320 - Specific treatment is urgent (see <...> on this label).',
  472.                             'de-DE' => 'P320 - Besondere Behandlung dringend erforderlich (siehe <...> auf diesem Kennzeichnungsetikett).',
  473.                             'fr-FR' => 'P320 - Un traitement spécifique est urgent (voir <…> sur cette étiquette).',
  474.                         ],
  475.                         'customFieldPosition' => 133,
  476.                     ],
  477.                 ],
  478.                 [
  479.                     'name' => 'lenz_platform_clp_product_p321_var1',
  480.                     'type' => CustomFieldTypes::TEXT,
  481.                     'config' => [
  482.                         'label' => [
  483.                             'en-GB' => 'P321 - Specific treatment (see <...> on this label).',
  484.                             'de-DE' => 'P321 - Besondere Behandlung (siehe <...> auf diesem Kennzeichnungsetikett).',
  485.                             'fr-FR' => 'P321 - Traitement spécifique (voir <…> sur cette étiquette).',
  486.                         ],
  487.                         'customFieldPosition' => 134,
  488.                     ],
  489.                 ],
  490.                 [
  491.                     'name' => 'lenz_platform_clp_product_p322_var1',
  492.                     'type' => CustomFieldTypes::TEXT,
  493.                     'config' => [
  494.                         'label' => [
  495.                             'en-GB' => 'P322 - Specific treatment (see <...> on this label).',
  496.                             'de-DE' => 'P322 - Gezielte Maßnahmen (siehe <...> auf diesem Kennzeichnungsetikett).',
  497.                             'fr-FR' => 'P322 - Mesures spécifiques (voir <...> sur cette étiquette).',
  498.                         ],
  499.                         'customFieldPosition' => 135,
  500.                     ],
  501.                 ],
  502.                 [
  503.                     'name' => 'lenz_platform_clp_product_p342_p311_var1',
  504.                     'type' => CustomFieldTypes::TEXT,
  505.                     'config' => [
  506.                         'label' => [
  507.                             'en-GB' => 'P342 + P311 - If experiencing respiratory symptoms:  Call a POISON CENTER/doctor/<...>',
  508.                             'de-DE' => 'P342 + P311 - Bei Symptomen der Atemwege: GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
  509.                             'fr-FR' => 'P342 + P311 - En cas de symptômes respiratoires: Appeler un CENTRE ANTIPOISON/un médecin/<...>',
  510.                         ],
  511.                         'customFieldPosition' => 136,
  512.                     ],
  513.                 ],
  514.                 [
  515.                     'name' => 'lenz_platform_clp_product_p352_var1',
  516.                     'type' => CustomFieldTypes::TEXT,
  517.                     'config' => [
  518.                         'label' => [
  519.                             'en-GB' => 'P352 - Wash with plenty of water/<...>',
  520.                             'de-DE' => 'P352 - Mit viel Wasser/<…>/waschen.',
  521.                             'fr-FR' => 'P352 - Laver abondamment à l\'eau/<…>',
  522.                         ],
  523.                         'customFieldPosition' => 137,
  524.                     ],
  525.                 ],
  526.                 [
  527.                     'name' => 'lenz_platform_clp_product_p378_var1',
  528.                     'type' => CustomFieldTypes::TEXT,
  529.                     'config' => [
  530.                         'label' => [
  531.                             'en-GB' => 'P378 - Use <...> to extinguish.',
  532.                             'de-DE' => 'P378 - <...> zum Löschen verwenden.',
  533.                             'fr-FR' => 'P378 - Utiliser <…> pour l\'extinction.',
  534.                         ],
  535.                         'customFieldPosition' => 137,
  536.                     ],
  537.                 ],
  538.                 [
  539.                     'name' => 'lenz_platform_clp_product_p370_p378_var1',
  540.                     'type' => CustomFieldTypes::TEXT,
  541.                     'config' => [
  542.                         'label' => [
  543.                             'en-GB' => 'P370 + P378 - In case of fire:  Use <...> to extinguish.',
  544.                             'de-DE' => 'P370 + P378 - Bei Brand: <…> zum Löschen verwenden.',
  545.                             'fr-FR' => 'P370 + P378 - En cas d\'incendie: Utiliser <…> pour l\'extinction.',
  546.                         ],
  547.                         'customFieldPosition' => 138,
  548.                     ],
  549.                 ],
  550.                 [
  551.                     'name' => 'lenz_platform_clp_product_p370_p380_p375_p378_var1',
  552.                     'type' => CustomFieldTypes::TEXT,
  553.                     'config' => [
  554.                         'label' => [
  555.                             'en-GB' => 'P370 + P380 + P375 + P378 - In case of fire: Evacuate area. Fight fire remotely due to the risk of explosion. [Use <…> to extinguish].',
  556.                             'fr-FR' => 'P370 + P380 + P375 + P378 - En cas d\'incendie: Évacuer la zone. Combattre l\'incendie à distance à cause du risque d\'explosion. [Utiliser <…> pour l\'extinction].',
  557.                         ],
  558.                         'customFieldPosition' => 139,
  559.                     ],
  560.                 ],
  561.                 [
  562.                     'name' => 'lenz_platform_clp_product_p401_var1',
  563.                     'type' => CustomFieldTypes::TEXT,
  564.                     'config' => [
  565.                         'label' => [
  566.                             'en-GB' => 'P401 - Store in accordance with <…>.',
  567.                             'de-DE' => 'P401 - Aufbewahren gemäß <…>.',
  568.                             'fr-FR' => 'P401 - Stocker conformément à <…>.',
  569.                         ],
  570.                         'customFieldPosition' => 140,
  571.                     ],
  572.                 ],
  573.                 [
  574.                     'name' => 'lenz_platform_clp_product_p406_var1',
  575.                     'type' => CustomFieldTypes::TEXT,
  576.                     'config' => [
  577.                         'label' => [
  578.                             'en-GB' => 'P406 - Store in a corrosion-resistant/<…> container with a resistant inner liner.',
  579.                             'de-DE' => 'P406 - In korrosionsbeständigem/<...> Behälter mit widerstandsfähiger Innenauskleidung aufbewahren.',
  580.                             'fr-FR' => 'P406 - Stocker dans un récipient résistant à la corrosion/<…> avec doublure intérieure.',
  581.                         ],
  582.                         'customFieldPosition' => 141,
  583.                     ],
  584.                 ],
  585.                 [
  586.                     'name' => 'lenz_platform_clp_product_p411_var1',
  587.                     'type' => CustomFieldTypes::TEXT,
  588.                     'config' => [
  589.                         'label' => [
  590.                             'en-GB' => 'P411 - Store at temperatures not exceeding <…°C/…°F.>',
  591.                             'de-DE' => 'P411 - Bei Temperaturen nicht über <... °C/...°F> aufbewahren.',
  592.                             'fr-FR' => 'P411 - Stocker à une température ne dépassant pas <... °C/... °F>.',
  593.                         ],
  594.                         'customFieldPosition' => 142,
  595.                     ],
  596.                 ],
  597.                 [
  598.                     'name' => 'lenz_platform_clp_product_p411_p235_var1',
  599.                     'type' => CustomFieldTypes::TEXT,
  600.                     'config' => [
  601.                         'label' => [
  602.                             'en-GB' => 'P411 + P235 - Store at temperatures not exceeding <... °C/...°F>. Keep cool.',
  603.                             'de-DE' => 'P411 + P235 - Bei Temperaturen nicht über <... °C/...°F> aufbewahren. Kühl halten.',
  604.                             'fr-FR' => 'P411 + P235 - Stocker à une température ne dépassant pas <... °C/... °F>. Tenir au frais.',
  605.                         ],
  606.                         'customFieldPosition' => 143,
  607.                     ],
  608.                 ],
  609.                 [
  610.                     'name' => 'lenz_platform_clp_product_p413_var1',
  611.                     'type' => CustomFieldTypes::TEXT,
  612.                     'config' => [
  613.                         'label' => [
  614.                             'en-GB' => 'P413 VAR1 - Store bulk masses greater than <… kg/…lbs> at temperatures not exceeding <…°C/…°F>.',
  615.                             'de-DE' => 'P413 VAR1 - Schüttgut in Mengen von mehr als <... kg/... lbs> bei Temperaturen nicht über <... °C/... °F> aufbewahren.',
  616.                             'fr-FR' => 'P413 VAR1 - Stocker les quantités en vrac de plus de <…kg/…lb> à une température ne dépassant pas <...°C/…°F.>',
  617.                         ],
  618.                         'customFieldPosition' => 144,
  619.                     ],
  620.                 ],
  621.                 [
  622.                     'name' => 'lenz_platform_clp_product_p413_var2',
  623.                     'type' => CustomFieldTypes::TEXT,
  624.                     'config' => [
  625.                         'label' => [
  626.                            'en-GB' => 'P413 VAR2 - Store bulk masses greater than <… kg/…lbs> at temperatures not exceeding <…°C/…°F>.',
  627.                             'de-DE' => 'P413 VAR2 - Schüttgut in Mengen von mehr als <... kg/... lbs> bei Temperaturen nicht über <... °C/... °F> aufbewahren.',
  628.                             'fr-FR' => 'P413 VAR2 - Stocker les quantités en vrac de plus de <…kg/…lb> à une température ne dépassant pas <...°C/…°F.>',
  629.                         ],
  630.                         'customFieldPosition' => 145,
  631.                     ],
  632.                 ],
  633.                 [
  634.                     'name' => 'lenz_platform_clp_product_p422_var1',
  635.                     'type' => CustomFieldTypes::TEXT,
  636.                     'config' => [
  637.                         'label' => [
  638.                             'en-GB' => 'P422 - Store contents under <...>',
  639.                             'de-DE' => 'P422 - Inhalt in/unter <...> aufbewahren.',
  640.                             'fr-FR' => 'P422 - Stocker le contenu sous <...>',
  641.                         ],
  642.                         'customFieldPosition' => 146,
  643.                     ],
  644.                 ],
  645.                 [
  646.                     'name' => 'lenz_platform_clp_product_p501_var1',
  647.                     'type' => CustomFieldTypes::TEXT,
  648.                     'config' => [
  649.                         'label' => [
  650.                             'en-GB' => 'P501 - Dispose of contents/container to <...>',
  651.                             'de-DE' => 'P501 - Inhalt/Behälter <...> zuführen.',
  652.                             'fr-FR' => 'P501 - Éliminer le contenu/récipient dans <…>',
  653.                         ],
  654.                         'customFieldPosition' => 147,
  655.                     ],
  656.                 ],
  657.                 [
  658.                     'name' => 'lenz_platform_clp_product_p503_var1',
  659.                     'type' => CustomFieldTypes::TEXT,
  660.                     'config' => [
  661.                         'label' => [
  662.                             'en-GB' => 'P503 - Refer to manufacturer/supplier <...> for information on disposal/recovery/recycling.',
  663.                             'de-DE' => 'P503 - Informationen zur Entsorgung/Wiederverwendung/Wiederverwertung beim Hersteller/Lieferanten/<...> erfragen',
  664.                         ],
  665.                         'customFieldPosition' => 148,
  666.                     ],
  667.                 ],
  668.             ],
  669.         ],
  670.     ];
  671.     private function findCustomFieldSet($name): ?CustomFieldSetEntity
  672.     {
  673.         /** @var EntityRepositoryInterface $customFieldSetRepository */
  674.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  675.         $criteria = new Criteria();
  676.         $criteria->addFilter(new EqualsFilter('name'$name));
  677.         $criteria->addAssociation('customFields');
  678.         $criteria->addAssociation('relations');
  679.         /** @var CustomFieldSetEntity|null $customFieldSet */
  680.         return $customFieldSetRepository->search($criteriaContext::createDefaultContext())->first();
  681.     }
  682.     public function createOrUpdateCustomFields($name)
  683.     {
  684.         /** @var EntityRepositoryInterface $customFieldSetRepository */
  685.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  686.         $customFieldSet $this->findCustomFieldSet($name);
  687.         $customFieldSetId null;
  688.         $customFieldName2Id = [];
  689.         $relationEntity2Id = [];
  690.         if(!empty($customFieldSet)) {
  691.             $customFieldSetId $customFieldSet->getId();
  692.             foreach ($customFieldSet->getCustomFields() as $customField) {
  693.                 $customFieldName2Id[$customField->getName()] = $customField->getId();
  694.             }
  695.             foreach ($customFieldSet->getRelations() as $relation) {
  696.                 $relationEntity2Id[$relation->getEntityName()] = $relation->getId();
  697.             }
  698.         }
  699.         $customFieldSet $this->customFieldSets[$name];
  700.         $customFieldSet['id'] = $customFieldSetId;
  701.         foreach ($customFieldSet['customFields'] as $customFieldKey => $customField) {
  702.             if(!array_key_exists($customField['name'], $customFieldName2Id)) {
  703.                 continue;
  704.             }
  705.             $customFieldSet['customFields'][$customFieldKey]['id'] = $customFieldName2Id[$customField['name']];
  706.         }
  707.         foreach ($customFieldSet['relations'] as $relationKey => $relation) {
  708.             if(!array_key_exists($relation['entityName'], $relationEntity2Id)) {
  709.                 continue;
  710.             }
  711.             $customFieldSet['relations'][$relationKey]['id'] = $relationEntity2Id[$relation['entityName']];
  712.         }
  713.         $customFieldSetRepository->upsert(
  714.             [ $customFieldSet ],
  715.             Context::createDefaultContext()
  716.         );
  717.     }
  718.     private function deleteCustomFieldSet(string $name)
  719.     {
  720.         /** @var EntityRepositoryInterface $customFieldSetRepository */
  721.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  722.         $customFieldSet $this->findCustomFieldSet($name);
  723.         if ($customFieldSet === null) {
  724.             return;
  725.         }
  726.         $customFieldSetRepository->delete(
  727.             [
  728.                 ['id' => $customFieldSet->getId()],
  729.             ],
  730.             Context::createDefaultContext()
  731.         );
  732.     }
  733. }