Pim-community-dev: 由于硬编码的表单类型,无法覆盖Akeneo 3上的类别实体

创建于 2019-04-03  ·  4评论  ·  资料来源: akeneo/pim-community-dev

你好,

我试图使用Akeneo CE 3.0.10覆盖Category实体以添加新属性,但这样做有些麻烦。

我或多或少都在关注官方文档,因为我知道它并不总是最新的。

我确实重写了Category类,没关系,但是不能重写Category表单。
这是逻辑,因为我刚刚注意到参数pim_enrich.form.type.category.class不再存在! 现在,已将使用的表单类型( Akeneo\Pim\Enrichment\Bundle\Form\Type\CategoryType硬编码为:-1:到这两个YAML文件中:

  • Akeneo/Pim/Enrichment/Bundle/Resources/config/form_types.yml
  • Akeneo/Pim/Enrichment/Bundle/Resources/config/controllers.yml

...而在Akeneo 2中还可以!

关于扩展Category实体还有另一个问题:#9833,我不知道是否链接。

你能尽快解决这个问题吗?

Rgds,
百灵

bug documentation

最有用的评论

嗨@peleq-微笑,
从2.3.x升级到3.0.x时,自定义类别实体存在相同的问题。
到目前为止,按照官方文档https://docs.akeneo.com/3.0/manipulate_pim_data/category/add_new_properties_to_a_category.html#define -the-category-form的指南,它仍然无法正常工作。 作为快速修复,我决定使用参数化的 FormType 类(您可能有一个覆盖 - 按照文档)在我自己的包中(例如在 Resources/config/controllers.yml 中)覆盖控制器的服务定义:

    pim_enrich.controller.category_tree.product:
        class: 'Akeneo\Pim\Enrichment\Bundle\Controller\Ui\CategoryTreeController'
        arguments:
            - '<strong i="9">@event_dispatcher</strong>'
            - '@pim_user.context.user'
            - '@pim_catalog.saver.category'
            - '@pim_catalog.remover.category'
            - '@pim_catalog.factory.category'
            - '@pim_catalog.repository.category'
            - '@oro_security.security_facade'
            - { related_entity: product, form_type: '%pim_enrich.form.type.category.class%', acl: pim_enrich_product, route: pim_enrich }
            - '@pimee_security.repository.category_access'
            - '@security.token_storage'
        calls:
            - [ setContainer, [ '<strong i="10">@service_container</strong>' ] ]

确保yml文件已正确加载到Your \ Custom \ Bundle \ DependencyInjection \ Extension.php中:

    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load("controllers.yml");
        [load your other configs...]
    }

所有4条评论

你好,

继续,我使用类的参数更新了两个文件(在供应商中,请不要这么快地判断我...这只是为了培训而不是真正的项目^^),以便能够覆盖它它的工作原理。

但是之后,我无法为类别的新“图像”属性添加MediaType表单元素,但这是另一个问题。 我想这是可能的,但我只是不知道该怎么做,因为 Akeneo 中没有其他带有“旧树枝前端”系统的 MediaType 属性示例:'

BR,
百灵

嗨@peleq-微笑,
你是如何解决这个问题的? 我是 symfony 的新手

嗨@peleq-微笑,
从2.3.x升级到3.0.x时,自定义类别实体存在相同的问题。
到目前为止,按照官方文档https://docs.akeneo.com/3.0/manipulate_pim_data/category/add_new_properties_to_a_category.html#define -the-category-form的指南,它仍然无法正常工作。 作为快速修复,我决定使用参数化的 FormType 类(您可能有一个覆盖 - 按照文档)在我自己的包中(例如在 Resources/config/controllers.yml 中)覆盖控制器的服务定义:

    pim_enrich.controller.category_tree.product:
        class: 'Akeneo\Pim\Enrichment\Bundle\Controller\Ui\CategoryTreeController'
        arguments:
            - '<strong i="9">@event_dispatcher</strong>'
            - '@pim_user.context.user'
            - '@pim_catalog.saver.category'
            - '@pim_catalog.remover.category'
            - '@pim_catalog.factory.category'
            - '@pim_catalog.repository.category'
            - '@oro_security.security_facade'
            - { related_entity: product, form_type: '%pim_enrich.form.type.category.class%', acl: pim_enrich_product, route: pim_enrich }
            - '@pimee_security.repository.category_access'
            - '@security.token_storage'
        calls:
            - [ setContainer, [ '<strong i="10">@service_container</strong>' ] ]

确保yml文件已正确加载到Your \ Custom \ Bundle \ DependencyInjection \ Extension.php中:

    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load("controllers.yml");
        [load your other configs...]
    }

嗨@ peleq-smile!

我们发布了文档的新修复程序。 它包含对“如何向类别添加新属性”页面的修复。

https://docs.akeneo.com/3.0/manipulate_pim_data/category/add_new_properties_to_a_category.html

请清理浏览器缓存以显示新版本。

问候,

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

tonongregory picture tonongregory  ·  15评论

oefterdal picture oefterdal  ·  13评论

mathewrapid picture mathewrapid  ·  13评论

simonkey picture simonkey  ·  12评论

Saadkhalid87 picture Saadkhalid87  ·  11评论