<?php declare(strict_types=1);
namespace LenzPlatformClp;
use Doctrine\DBAL\Connection;
use Exception;
use LenzPlatformClp\Core\Content\Clp\Service\ClpImportService;
use LenzPlatformClp\Core\Content\Clp\Service\ClpService;
use LenzPlatformClp\Core\Content\Clp\Service\Importer\CsvImporter;
use LenzPlatformClp\Core\Content\Clp\Service\UpdateClpStrategy;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\System\CustomField\Aggregate\CustomFieldSet\CustomFieldSetEntity;
use Shopware\Core\System\CustomField\CustomFieldTypes;
class LenzPlatformClp extends Plugin
{
public function install(InstallContext $installContext): void
{
$this->createOrUpdateCustomFields('lenz_platform_clp_product');
}
public function activate(Plugin\Context\ActivateContext $activateContext): void
{
/** @var ClpImportService $clpService */
$clpImportService = $this->container->get(ClpImportService::class);
$clpImportService->import();
}
public function update(UpdateContext $updateContext): void
{
$this->createOrUpdateCustomFields('lenz_platform_clp_product');
}
public function postUpdate(UpdateContext $updateContext): void
{
if($this->container->has(ClpImportService::class)) {
/** @var ClpImportService $clpService */
$clpImportService = $this->container->get(ClpImportService::class);
$clpImportService->import();
}
}
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if (!$context->keepUserData()) {
$connection = $this->container->get(Connection::class);
try {
// Drop binary column for the variants
$connection->executeStatement('ALTER TABLE `product` DROP COLUMN `lenzPlatformClp`');
} catch(Exception $e) {
echo "Column \"clp\" on \"product\" not deleted.\n\r";
}
$tablesToDelete = [
'lenz_platform_clp_product',
'lenz_platform_clp_translation',
'lenz_platform_clp',
];
foreach ($tablesToDelete as $table) {
try {
$connection->executeStatement('DROP TABLE IF EXISTS `' . $table . '`');
} catch(Exception $e) {
echo "Table \"" . $table . "\" not deleted.\n\r";
}
}
$this->deleteCustomFieldSet('lenz_platform_clp_product');
}
}
// -- Custom fields
private array $customFieldSets = [
'lenz_platform_clp_product' => [
'name' => 'lenz_platform_clp_product',
'config' => [
'label' => [
'en-GB' => 'CLP/REACH - Product',
'de-DE' => 'CLP/REACH - Produkt',
],
],
'relations' => [
['entityName' => 'product']
],
'customFields' => [
[
'name' => 'lenz_platform_clp_product_euh208_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'EUH208 - Contains <name of sensitising substance>. May produce an allergic reaction.',
'de-DE' => 'EUH208 - Enthält <Name des sensibilisierenden Stoffes>. Kann allergische Reaktionen hervorrufen.',
'fr-FR' => 'EUH208 - Contient <nom de la substance sensibilisante>. Peut produire une réaction allergique.',
],
'customFieldPosition' => 101,
],
],
[
'name' => 'lenz_platform_clp_product_h340_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'de-DE' => 'H340 - Kann genetische Defekte verursachen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
'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>.',
],
'customFieldPosition' => 102,
],
],
[
'name' => 'lenz_platform_clp_product_h341_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'de-DE' => 'H341 - Kann vermutlich genetische Defekte verursachen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
'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>',
],
'customFieldPosition' => 103,
],
],
[
'name' => 'lenz_platform_clp_product_h350_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'H350 - May cause cancer <state route of exposure if it is conclusively proven that no other routes of exposure cause the hazard>',
'de-DE' => 'H350 - Kann Krebs erzeugen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
'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>',
],
'customFieldPosition' => 104,
],
],
[
'name' => 'lenz_platform_clp_product_h351_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'de-DE' => 'H351 - Kann vermutlich Krebs erzeugen <Expositionsweg angeben, sofern schlüssig belegt ist, dass diese Gefahr bei keinem anderen Expositionsweg besteht>.',
'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>',
],
'customFieldPosition' => 105,
],
],
[
'name' => 'lenz_platform_clp_product_h360_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>',
'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>',
],
'customFieldPosition' => 106,
],
],
[
'name' => 'lenz_platform_clp_product_h360_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>',
'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>',
],
'customFieldPosition' => 107,
],
],
[
'name' => 'lenz_platform_clp_product_h361_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'de-DE' => 'H361 VAR1 - Kann vermutlich die Fruchtbarkeit beeinträchtigen oder das Kind im Mutterleib schädigen <konkrete Wirkung angeben, sofern bekannt>',
'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>',
],
'customFieldPosition' => 108,
],
],
[
'name' => 'lenz_platform_clp_product_h361_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>',
],
'customFieldPosition' => 109,
],
],
[
'name' => 'lenz_platform_clp_product_h370_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 110,
],
],
[
'name' => 'lenz_platform_clp_product_h370_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 111,
],
],
[
'name' => 'lenz_platform_clp_product_h371_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 112,
],
],
[
'name' => 'lenz_platform_clp_product_h371_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 113,
],
],
[
'name' => 'lenz_platform_clp_product_h372_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 114,
],
],
[
'name' => 'lenz_platform_clp_product_h372_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 115,
],
],
[
'name' => 'lenz_platform_clp_product_h373_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 116,
],
],
[
'name' => 'lenz_platform_clp_product_h373_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'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>',
'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>.',
'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>',
],
'customFieldPosition' => 117,
],
],
[
'name' => 'lenz_platform_clp_product_p221_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P221 - Take any precaution to avoid mixing with combustibles <...>',
'de-DE' => 'P221 - Mischen mit brennbaren Stoffen/<...> unbedingt verhindern.',
'fr-FR' => 'P221 - Prendre toutes précautions pour éviter de mélanger avec des matières combustibles <...>',
],
'customFieldPosition' => 118,
],
],
[
'name' => 'lenz_platform_clp_product_p230_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P230 - Keep wetted with <...>',
'de-DE' => 'P230 - Feucht halten mit <...>',
'fr-FR' => 'P230 - Maintenir humidifié avec <...>',
],
'customFieldPosition' => 119,
],
],
[
'name' => 'lenz_platform_clp_product_p231_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P231 - Handle and store contents under inert gas/<...>',
'de-DE' => 'P231 - Inhalt unter inertem Gas/<…> handhaben und aufbewahren.',
'fr-FR' => 'P231 - Manipuler et stocker le contenu sous gaz inerte/<…>',
],
'customFieldPosition' => 120,
],
],
[
'name' => 'lenz_platform_clp_product_p231_p232_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P231 + P232 - Handle and store contents under inert gas/<…>. Protect from moisture.',
'de-DE' => 'P231 + P232 - Inhalt unter inertem Gas/<…> handhaben und aufbewahren. Vor Feuchtigkeit schützen.',
'fr-FR' => 'P231 + P232 - Manipuler et stocker le contenu sous gaz inerte/<…> Protéger de l\'humidité.',
],
'customFieldPosition' => 121,
],
],
[
'name' => 'lenz_platform_clp_product_p241_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P241 - Use explosion-proof [electrical/ventilating/lighting/<…>] equipment.',
'de-DE' => 'P241 - Explosionsgeschützte elektrische Geräte/Lüftungsanlagen/Beleuchtungsanlagen/<...> verwenden.',
'fr-FR' => 'P241 - Utiliser du matériel [électrique/de ventilation/d\'éclairage/<…>] antidéflagrant.',
],
'customFieldPosition' => 122,
],
],
[
'name' => 'lenz_platform_clp_product_p250_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P250 - Do not subject to grinding/shock/friction/<…>.',
'de-DE' => 'P250 - Nicht schleifen/stoßen/reiben/<…>.',
'fr-FR' => 'P250 - Éviter les abrasions/les chocs/les frottements/<…>.',
],
'customFieldPosition' => 123,
],
],
[
'name' => 'lenz_platform_clp_product_p264_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P264 - Wash <...> thoroughly after handling.',
'de-DE' => 'P264 - Nach Gebrauch <...> gründlich waschen.',
'fr-FR' => 'P264 - Se laver <...> soigneusement après manipulation.',
],
'customFieldPosition' => 124,
],
],
[
'name' => 'lenz_platform_clp_product_p280_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P280 - Wear protective gloves/protective clothing/eye protection/face protection/hearing protection/<...>',
'de-DE' => 'P280 - Schutzhandschuhe/ Schutzkleidung/Augenschutz/ Gesichtsschutz/Gehörschutz/<…> tragen',
'fr-FR' => 'P280 - Porter des gants de protection/des vêtements de protection/un équipement de protection des yeux/du visage/une protection auditive/ <...>',
],
'customFieldPosition' => 125,
],
],
[
'name' => 'lenz_platform_clp_product_p301_p310_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P301 + P310 - IF SWALLOWED: Immediately call a POISON CENTER/doctor/<…>',
'de-DE' => 'P301 + P310 - BEI VERSCHLUCKEN: Sofort GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
'fr-FR' => 'P301 + P310 - EN CAS D\'INGESTION: Appeler immédiatement un CENTRE ANTIPOISON/un médecin/<…>',
],
'customFieldPosition' => 126,
],
],
[
'name' => 'lenz_platform_clp_product_p301_p312_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P301 + P312 - Call a POISON CENTRE/doctor/<…> if you feel unwell.',
'de-DE' => 'P301 + P312 - BEI VERSCHLUCKEN: Bei Unwohlsein GIFTINFORMATIONSZENTRUM/Arzt/<…> anrufen.',
'fr-FR' => 'P301 + P312 - EN CAS D\'INGESTION: Appeler un CENTRE ANTIPOISON/un médecin/<…>/ en cas de malaise.',
],
'customFieldPosition' => 127,
],
],
[
'name' => 'lenz_platform_clp_product_p302_p352_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P302 + P312 - Wash with plenty of water/<...>',
'de-DE' => 'P302 + P312 - BERÜHRUNG MIT DER HAUT: Mit viel Wasser/<…>/waschen.',
'fr-FR' => 'P302 + P312 - EN CAS DE CONTACT AVEC LA PEAU: Laver abondamment à l\'eau/<...>',
],
'customFieldPosition' => 128,
],
],
[
'name' => 'lenz_platform_clp_product_p308_p311_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P308 + P311 - IF exposed or concerned: Call a POISON CENTER/doctor/<...>',
'de-DE' => 'P308 + P311 - BEI Exposition oder falls betroffen: GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
'fr-FR' => 'P308 + P311 - EN CAS d\'exposition prouvée ou suspectée: Appeler un CENTRE ANTIPOISON/un médecin/<...>',
],
'customFieldPosition' => 129,
],
],
[
'name' => 'lenz_platform_clp_product_p310_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P310 - Immediately call a POISON CENTER/doctor/<…>',
'de-DE' => 'P310 - Sofort GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
'fr-FR' => 'P310 - Appeler immédiatement un CENTRE ANTIPOISON/un médecin/<...>',
],
'customFieldPosition' => 130,
],
],
[
'name' => 'lenz_platform_clp_product_p311_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P311 - Call a POISON CENTER/doctor/<…>',
'de-DE' => 'P311 - GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
'fr-FR' => 'P311 - Appeler un CENTRE ANTIPOISON/un médecin<...>',
],
'customFieldPosition' => 131,
],
],
[
'name' => 'lenz_platform_clp_product_p312_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P312 - Call a POISON CENTRE/doctor/<…> if you feel unwell.',
'de-DE' => 'P312 - Bei Unwohlsein GIFTINFORMATIONSZENTRUM/Arzt/<…> anrufen.',
'fr-FR' => 'P312 - Appeler un CENTRE ANTIPOISON/un médecin/<…> en cas de malaise',
],
'customFieldPosition' => 132,
],
],
[
'name' => 'lenz_platform_clp_product_p320_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P320 - Specific treatment is urgent (see <...> on this label).',
'de-DE' => 'P320 - Besondere Behandlung dringend erforderlich (siehe <...> auf diesem Kennzeichnungsetikett).',
'fr-FR' => 'P320 - Un traitement spécifique est urgent (voir <…> sur cette étiquette).',
],
'customFieldPosition' => 133,
],
],
[
'name' => 'lenz_platform_clp_product_p321_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P321 - Specific treatment (see <...> on this label).',
'de-DE' => 'P321 - Besondere Behandlung (siehe <...> auf diesem Kennzeichnungsetikett).',
'fr-FR' => 'P321 - Traitement spécifique (voir <…> sur cette étiquette).',
],
'customFieldPosition' => 134,
],
],
[
'name' => 'lenz_platform_clp_product_p322_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P322 - Specific treatment (see <...> on this label).',
'de-DE' => 'P322 - Gezielte Maßnahmen (siehe <...> auf diesem Kennzeichnungsetikett).',
'fr-FR' => 'P322 - Mesures spécifiques (voir <...> sur cette étiquette).',
],
'customFieldPosition' => 135,
],
],
[
'name' => 'lenz_platform_clp_product_p342_p311_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P342 + P311 - If experiencing respiratory symptoms: Call a POISON CENTER/doctor/<...>',
'de-DE' => 'P342 + P311 - Bei Symptomen der Atemwege: GIFTINFORMATIONSZENTRUM/Arzt/<…>/anrufen.',
'fr-FR' => 'P342 + P311 - En cas de symptômes respiratoires: Appeler un CENTRE ANTIPOISON/un médecin/<...>',
],
'customFieldPosition' => 136,
],
],
[
'name' => 'lenz_platform_clp_product_p352_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P352 - Wash with plenty of water/<...>',
'de-DE' => 'P352 - Mit viel Wasser/<…>/waschen.',
'fr-FR' => 'P352 - Laver abondamment à l\'eau/<…>',
],
'customFieldPosition' => 137,
],
],
[
'name' => 'lenz_platform_clp_product_p378_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P378 - Use <...> to extinguish.',
'de-DE' => 'P378 - <...> zum Löschen verwenden.',
'fr-FR' => 'P378 - Utiliser <…> pour l\'extinction.',
],
'customFieldPosition' => 137,
],
],
[
'name' => 'lenz_platform_clp_product_p370_p378_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P370 + P378 - In case of fire: Use <...> to extinguish.',
'de-DE' => 'P370 + P378 - Bei Brand: <…> zum Löschen verwenden.',
'fr-FR' => 'P370 + P378 - En cas d\'incendie: Utiliser <…> pour l\'extinction.',
],
'customFieldPosition' => 138,
],
],
[
'name' => 'lenz_platform_clp_product_p370_p380_p375_p378_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P370 + P380 + P375 + P378 - In case of fire: Evacuate area. Fight fire remotely due to the risk of explosion. [Use <…> to extinguish].',
'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].',
],
'customFieldPosition' => 139,
],
],
[
'name' => 'lenz_platform_clp_product_p401_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P401 - Store in accordance with <…>.',
'de-DE' => 'P401 - Aufbewahren gemäß <…>.',
'fr-FR' => 'P401 - Stocker conformément à <…>.',
],
'customFieldPosition' => 140,
],
],
[
'name' => 'lenz_platform_clp_product_p406_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P406 - Store in a corrosion-resistant/<…> container with a resistant inner liner.',
'de-DE' => 'P406 - In korrosionsbeständigem/<...> Behälter mit widerstandsfähiger Innenauskleidung aufbewahren.',
'fr-FR' => 'P406 - Stocker dans un récipient résistant à la corrosion/<…> avec doublure intérieure.',
],
'customFieldPosition' => 141,
],
],
[
'name' => 'lenz_platform_clp_product_p411_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P411 - Store at temperatures not exceeding <…°C/…°F.>',
'de-DE' => 'P411 - Bei Temperaturen nicht über <... °C/...°F> aufbewahren.',
'fr-FR' => 'P411 - Stocker à une température ne dépassant pas <... °C/... °F>.',
],
'customFieldPosition' => 142,
],
],
[
'name' => 'lenz_platform_clp_product_p411_p235_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P411 + P235 - Store at temperatures not exceeding <... °C/...°F>. Keep cool.',
'de-DE' => 'P411 + P235 - Bei Temperaturen nicht über <... °C/...°F> aufbewahren. Kühl halten.',
'fr-FR' => 'P411 + P235 - Stocker à une température ne dépassant pas <... °C/... °F>. Tenir au frais.',
],
'customFieldPosition' => 143,
],
],
[
'name' => 'lenz_platform_clp_product_p413_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P413 VAR1 - Store bulk masses greater than <… kg/…lbs> at temperatures not exceeding <…°C/…°F>.',
'de-DE' => 'P413 VAR1 - Schüttgut in Mengen von mehr als <... kg/... lbs> bei Temperaturen nicht über <... °C/... °F> aufbewahren.',
'fr-FR' => 'P413 VAR1 - Stocker les quantités en vrac de plus de <…kg/…lb> à une température ne dépassant pas <...°C/…°F.>',
],
'customFieldPosition' => 144,
],
],
[
'name' => 'lenz_platform_clp_product_p413_var2',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P413 VAR2 - Store bulk masses greater than <… kg/…lbs> at temperatures not exceeding <…°C/…°F>.',
'de-DE' => 'P413 VAR2 - Schüttgut in Mengen von mehr als <... kg/... lbs> bei Temperaturen nicht über <... °C/... °F> aufbewahren.',
'fr-FR' => 'P413 VAR2 - Stocker les quantités en vrac de plus de <…kg/…lb> à une température ne dépassant pas <...°C/…°F.>',
],
'customFieldPosition' => 145,
],
],
[
'name' => 'lenz_platform_clp_product_p422_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P422 - Store contents under <...>',
'de-DE' => 'P422 - Inhalt in/unter <...> aufbewahren.',
'fr-FR' => 'P422 - Stocker le contenu sous <...>',
],
'customFieldPosition' => 146,
],
],
[
'name' => 'lenz_platform_clp_product_p501_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P501 - Dispose of contents/container to <...>',
'de-DE' => 'P501 - Inhalt/Behälter <...> zuführen.',
'fr-FR' => 'P501 - Éliminer le contenu/récipient dans <…>',
],
'customFieldPosition' => 147,
],
],
[
'name' => 'lenz_platform_clp_product_p503_var1',
'type' => CustomFieldTypes::TEXT,
'config' => [
'label' => [
'en-GB' => 'P503 - Refer to manufacturer/supplier <...> for information on disposal/recovery/recycling.',
'de-DE' => 'P503 - Informationen zur Entsorgung/Wiederverwendung/Wiederverwertung beim Hersteller/Lieferanten/<...> erfragen',
],
'customFieldPosition' => 148,
],
],
],
],
];
private function findCustomFieldSet($name): ?CustomFieldSetEntity
{
/** @var EntityRepositoryInterface $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('name', $name));
$criteria->addAssociation('customFields');
$criteria->addAssociation('relations');
/** @var CustomFieldSetEntity|null $customFieldSet */
return $customFieldSetRepository->search($criteria, Context::createDefaultContext())->first();
}
public function createOrUpdateCustomFields($name)
{
/** @var EntityRepositoryInterface $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFieldSet = $this->findCustomFieldSet($name);
$customFieldSetId = null;
$customFieldName2Id = [];
$relationEntity2Id = [];
if(!empty($customFieldSet)) {
$customFieldSetId = $customFieldSet->getId();
foreach ($customFieldSet->getCustomFields() as $customField) {
$customFieldName2Id[$customField->getName()] = $customField->getId();
}
foreach ($customFieldSet->getRelations() as $relation) {
$relationEntity2Id[$relation->getEntityName()] = $relation->getId();
}
}
$customFieldSet = $this->customFieldSets[$name];
$customFieldSet['id'] = $customFieldSetId;
foreach ($customFieldSet['customFields'] as $customFieldKey => $customField) {
if(!array_key_exists($customField['name'], $customFieldName2Id)) {
continue;
}
$customFieldSet['customFields'][$customFieldKey]['id'] = $customFieldName2Id[$customField['name']];
}
foreach ($customFieldSet['relations'] as $relationKey => $relation) {
if(!array_key_exists($relation['entityName'], $relationEntity2Id)) {
continue;
}
$customFieldSet['relations'][$relationKey]['id'] = $relationEntity2Id[$relation['entityName']];
}
$customFieldSetRepository->upsert(
[ $customFieldSet ],
Context::createDefaultContext()
);
}
private function deleteCustomFieldSet(string $name)
{
/** @var EntityRepositoryInterface $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFieldSet = $this->findCustomFieldSet($name);
if ($customFieldSet === null) {
return;
}
$customFieldSetRepository->delete(
[
['id' => $customFieldSet->getId()],
],
Context::createDefaultContext()
);
}
}