【问题标题】:Akeneo: Edit an attribute optionAkeneo:编辑属性选项
【发布时间】:2015-11-19 15:25:38
【问题描述】:

我想更改属性选项标签并将其存储在 Akeneo 1.4.9 中,但我不知道应该使用哪些处理程序/工厂。

我使用MyAttributeOptionValueInterface->setLabel('new Label') 更改标签。如何将结果保存到数据库中?

我的想法:

  1. 从属性中删除旧选项 (AttributeInterface->removeOption(optionWithOldLabel))
  2. 再次添加 (AttributeInterface->addOption(optionWithNewLabel))
  3. 将属性存储在数据库中(如何?)。

这是正确的方法吗?欢迎任何提示。

【问题讨论】:

    标签: akeneo


    【解决方案1】:

    您可以使用 PIM 的对象保存程序:http://docs.akeneo.com/latest/cookbook/catalog/common/save.html?highlight=saver

    然后像这样保存您的选项:

    $attributeOption->setLabel('My nice label');
    $attributeOptionSaver = $this->getContainer()->get('pim_catalog.saver.attribute_option');
    $attributeOptionSaver->save($attributeOption);
    

    你很高兴!

    【讨论】:

    • 谢谢,更新 AttributeOption 适用于您的回答:-)。一个相关问题:当​​我想添加/删除属性选项时,我必须使用 AttributeInterface 吗?如何保存这些更改?
    • 好的,找到了:添加属性选项我也可以使用optionSaver (SaverInterface),删除属性我可以使用optionRemover (RemoverInterface)
    • 是的,您可以使用 propertyAdder 和 propertyRemover(您可以在这里找到详细信息:docs.akeneo.com/latest/cookbook/catalog/product/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多