Thursday, May 12, 2022

[FIXED] How to decorate entity definition in shopware 6

Issue

I would like to decorate entity definition in plugin shopware 6 to add some modifications. I wolud like to change length string field from standard 255 to 4000.

Definition class to change

my decorate class class with

change length string field

my config service

<service id="MyPlugin\Core\Content\Entities\AttributeTranslationDefinitionDecorator"
        decorates="TestPlugin\Entities\Attribute\Translation\AttributeTranslationDefinition" public="false">
        <argument type="service" id="MyPlugin\Core\Content\Entities\AttributeTranslationDefinitionDecorator.inner" />
    </service>

but this not work. I have tried all the ways with pages https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/adjusting-service or https://symfony.com/doc/current/service_container/service_decoration.html

Is it possible to change entity definition in other plugins?


Solution

Decorating entity definitions is not possible, you can't simply change the existing field definitions of the core entities. Instead you can add an EntityExtension if you want to add more fields to an existing entity. Please refer to the official docs.



Answered By - j_elfering
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.