是否以编程方式更新magento中属性的前端标签?

是否以编程方式更新magento中属性的前端标签?,magento,Magento,我有一个带有某些属性前端标签的属性。但我想更改产品的前端标签。magento中是否提供了任何函数以编程方式执行此操作 如果是,如何做到这一点 谢谢,如果您想为每个门店视图设置前端门店标签,您可以下一步操作(此代码用于custemer属性,但您可以通过此方式为所有类型的EAV属性设置前端标签): 我找到了更简单的方法来解决我的问题 $attributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_produ

我有一个带有某些属性前端标签的属性。但我想更改产品的前端标签。magento中是否提供了任何函数以编程方式执行此操作

如果是,如何做到这一点


谢谢,

如果您想为每个门店视图设置前端门店标签,您可以下一步操作(此代码用于custemer属性,但您可以通过此方式为所有类型的EAV属性设置前端标签):


我找到了更简单的方法来解决我的问题

$attributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', 'ATTRIBUTE_CODE');
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attribute->setFrontendLabel($displayName)->save();

setFrontendLabel(string$str)是最适合这里的功能。

最安全的方法是加载现有标签,然后添加新的商店特定标签:

1-检索所有存储的现有标签

Mage::getModel('eav/entity_attribute')->getResource()
   ->getStoreLabelsByAttributeId($attributeId);

2-添加自定义标签

$labels[$storeId] = 'My new label for a specific store';

$attribute->setStoreLabels($labels)->save();

实际上,您可以使用代码中的第3行和第4行
$attribute=Mage::getModel('catalog/resource\eav\u attribute')->load($attributeid)$属性->设置前端标签($displayName)->保存()
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$labels= $attribute->getStoreLabels();
$labels[$storeId] = 'My new label for a specific store';

$attribute->setStoreLabels($labels)->save();