【问题标题】:How to decorate entity definition in shopware 6如何在 shopware 6 中装饰实体定义
【发布时间】:2021-12-28 10:45:23
【问题描述】:

我想在插件 shopware 6 中装饰实体定义以添加一些修改。我想将长度字符串字段从标准 255 更改为 4000。

我的装饰类用

我的配置服务

<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>

但这不起作用。我已经尝试了所有页面的方式 https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/adjusting-servicehttps://symfony.com/doc/current/service_container/service_decoration.html

是否可以在其他插件中更改实体定义?

【问题讨论】:

    标签: symfony symfony5 shopware shopware6


    【解决方案1】:

    装饰实体定义是不可能的,您不能简单地更改核心实体的现有字段定义。相反,如果您想向现有实体添加更多字段,则可以添加 EntityExtension。请参考official docs

    【讨论】:

    • 感谢您的回答。不幸的是,扩展表格并不能解决我的问题,因为我需要更改字段长度。在这种情况下,如果我必须通过扩展添加其他字段,我将不得不更改整个插件,因为一切都使用它。
    • 所以如果我不能更改实体定义,唯一的选择就是修改插件并将其上传到您自己的存储库,对吧?
    • 是的,这将是要走的路。
    • 如果你使用 composer 安装插件,你可以使用 composer-patches github.com/vaimo/composer-patches - 但我认为应该联系插件供应商并询问他们是否接受你的补丁(也许你需要使长度可配置)
    • 我使用 composer-patches 来更改定义并且它有效!感谢您解决问题。
    猜你喜欢
    • 2021-08-01
    • 1970-01-01
    • 2022-08-19
    • 2023-01-31
    • 1970-01-01
    • 2022-07-08
    • 2020-10-30
    • 2021-11-10
    • 2023-04-06
    相关资源
    最近更新 更多