Wie erstelle ich ein Plugin das Zusatzfelder automatisch generiert?

Guten Tag,

ich bin langsam am verzweifeln …

Ich habe ein Plugin erstellt nach ( https://docs.shopware.com/en/shopware-platform-dev-en/developer-guide/custom-fields#global-custom-field-sets )das mir nach Installieren und aktivieren des Plugins automatisch Zusatzfelder generiert.

 

Mein Code sieht wie folgt aus:

_namespace_ InstallCustomfields\Service\Core\System\CustomFields; _use_ Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; _class_ SwagCustomFieldSetService { _/\*\*_ _\*_ _@var_ _EntityRepositoryInterface_ _\*/_ _private_ $customFieldSetRepository; _public function_ \_\_construct(EntityRepositoryInterface $customFieldSetRepository) { $this-\>customFieldSetRepository = $customFieldSetRepository; _// ..._ } _public function_ create($context): _void_ { $this-\>customFieldSetRepository-\>create([[ 'name' =\> 'swag\_example\_set', 'global' =\> true, 'config' =\> [ 'label' =\> [ 'de-DE' =\> 'Beispiel Plugin Zusatzfeld Set', 'en-GB' =\> 'Example plugin custom field set'] ], 'relations' =\> [['entityName' =\> 'product']], 'customFields' =\> [['name' =\> 'swag\_example\_size', 'type' =\> CustomFieldTypes::INT], ['name' =\> 'swag\_example\_color', 'type' =\> CustomFieldTypes::TEXT] ] ] ], $context); } }

 

 

services.xml:

 

 

 

 

Was mache ich falsch?

 

Mit freundlichen Grüßen

Federico

1 „Gefällt mir“