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.
my decorate class class with change length string field
...
return new FieldCollection([
(new StringField('label','label', 4000))->addFlags(new Required()),
new StringField('description','description', 4000),
new StringField('error_msg','errorMsg'),
new StringField('error_msg_min','errorMsgMin'),
new StringField('error_msg_max','errorMsgMax'),
]);
...
Thanks for the reply, That’s how I did it, unfortunately changing on the base is not enough because it still locks me on the definition. StringField is 255 characters by default.
What you did was correct. You have to override/decorate the service and in addition change it in the database manually, if you did not use a migration.
Ok but the entity decoration is not working. I changed length in the database by migration but it is not enough, still blocking me on entity definition. So if I want to change the length of the field, I have to change the existing plugin and put it in my repository?
You have to decorate the entity like it is described in the developer manual. If decorating is not possible, you can override it. It’s pretty the same, just without the decorates methods.
Still, your limitation could result through a different location, e.g. in the theme, a different method, …
you can set the class in the services.xml to the class of your desired adaptation class. It’s more an overwriting than a decoration but it would solve your problem:
<service id="TestPlugin\Entities\Attribute\Translation\AttributeTranslationDefinition"
class="MyPlugin\Core\Content\Entities\AttributeTranslationDefinitionDecorator" public="false">
<!-- Original arguments here -->
</service>