为客户属性设置前端标签 - Magento

3

我有一个客户属性,是使用以下脚本设置的(我只粘贴了与该属性相关的部分)

$setup->addAttribute('customer', 'age', array(
    'label'             => 'Age',
    'type'              => 'int',
    'input'             => 'select',
    'user_defined'      => true,
    'source'            => 'eav/entity_attribute_source_table',
    'visible'           => true,
    'required'          => false,
    'visible_on_front'  => true
));

我希望将属性的前端标签设置为“您多大了?”,但保留管理员标签为“年龄”。我该如何做到这一点?
提前感谢。

我也遇到了这个问题,从未成功地在属性的初始创建过程中使标签保持。不得不采用您下面的答案。然而,一个建议是使用$setup->_prepareValues($data_array);来初始化第三个参数addAttribute()的数组。这将返回一个包含设置属性的所有有效选项键的数组。 - Darren Felton
1个回答

3

我查看了Magento,现在已经解决了。

$labels = array();
$labels[0] = 'Age';//default store label
$labels[1] = 'Label for store with id 1';
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'age');
$oAttribute->setData('store_labels', $labels);
$oAttribute->save();

这就是解决问题的方法。

希望能对其他人有所帮助。


为了更新产品属性,我必须使用以下代码:Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'attribute_code')->setData('frontend_label', array('New Frontend Label for Store 0', 'New Frontend Label for Store 1'))->save(); - Louis B.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接