Akeneo:编辑属性选项
Akeneo: Edit an attribute option
我想更改属性选项标签并使用 Akeneo 1.4.9 存储它,但我不知道应该使用哪个 handlers/factories。
我用了MyAttributeOptionValueInterface->setLabel('new Label')
来更改标签。如何将结果保存在数据库中?
我的想法:
- 从属性中删除旧选项 (
AttributeInterface->removeOption(optionWithOldLabel)
)
- 重新添加(
AttributeInterface->addOption(optionWithNewLabel)
)
- 将属性存储在数据库中(如何?)。
这是正确的方法吗?欢迎任何提示。
您可以使用 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);
你很高兴去!
我想更改属性选项标签并使用 Akeneo 1.4.9 存储它,但我不知道应该使用哪个 handlers/factories。
我用了MyAttributeOptionValueInterface->setLabel('new Label')
来更改标签。如何将结果保存在数据库中?
我的想法:
- 从属性中删除旧选项 (
AttributeInterface->removeOption(optionWithOldLabel)
) - 重新添加(
AttributeInterface->addOption(optionWithNewLabel)
) - 将属性存储在数据库中(如何?)。
这是正确的方法吗?欢迎任何提示。
您可以使用 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);
你很高兴去!