【问题标题】:Akeneo 2.1.4 : How can I use an attribute value as label for a product model in the datagrid?Akeneo 2.1.4:如何使用属性值作为数据网格中产品模型的标签?
【发布时间】:2018-02-23 13:30:51
【问题描述】:

当我在 Akeneo 2.1.4 中使用产品模型时,我在标签列中看到了产品模型的代码。但我想在那里显示特定属性的值;例如namegroup name。我怎样才能做到这一点?

编辑:

我尝试扩展类并用我自己的entities.yml 重写它:

parameters:
    # Rewrite product model so we can override the getLabel()-method:
    pim_catalog.entity.product_model.class: Vendor\Bundle\AppBundle\Model\ProductModel

然后我得到错误:

The class 'Vendor\Bundle\AppBundle\Model\ProductModel' was not found in the chain configured namespaces 
    Gedmo\Tree\Entity, 
    Oro\Bundle\ConfigBundle\Entity, 
    Oro\Bundle\UserBundle\Entity, 
    Pim\Bundle\CustomEntityBundle\Entity, 
    FOS\OAuthServerBundle\Entity, 
    Pim\Bundle\UserBundle\Entity, 
    Pim\Bundle\ApiBundle\Entity, 
    Pim\Bundle\CatalogBundle\Entity, 
    Pim\Bundle\CommentBundle\Entity, 
    Pim\Bundle\DataGridBundle\Entity, 
    Pim\Bundle\NotificationBundle\Entity, 
    Akeneo\Component\Batch\Model, 
    Akeneo\Component\BatchQueue\Queue, 
    Akeneo\Component\FileStorage\Model, 
    Pim\Component\Catalog\Model, 
    Akeneo\Component\Versioning\Model

【问题讨论】:

    标签: php symfony doctrine akeneo


    【解决方案1】:

    您无需编写自定义代码即可实现此目的。在 Akeneo PIM 中,您可以定义您的家庭属性中的哪一个将用作网格上的标签

    当你编辑你的一个家庭时,你可以选择你想要的属性:

    选择后,您可以保存您的家庭,所选属性将用作网格中的标签(显然仅适用于属于该家庭的产品)。

    如果我不明白你真正的问题,请告诉我。

    【讨论】:

    • 我想出了这个解决方案,但就我而言,我有不同的属性想用作标签。例如:我希望将“name”用于我的产品,但将“group_name”用于我的产品型号。但我已经通过扩展Pim\Bundle\DataGridBundle\Normalizer\ProductModelNormalizer::normalize() 和操作$data['label']-property 找到了一个可行的解决方案。
    • 好的,我现在看到你的问题了。很高兴您找到了解决方案。确实,这是做这些事情的正确地方!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多