我可以使用magento中的属性脚本设置默认商店视图标签

Sco*_*t S 4 php magento entity-attribute-value

我正在使用模块在客户模型上创建新属性.有谁知道如何使用我的设置脚本设置默认商店视图?

管理员截图

我目前的剧本:

$setup = new Mage_Customer_Model_Resource_Setup('customer_setup');

if (! $setup->getAttribute('customer', 'dob_month')) {
    $setup->addAttribute('customer', 'dob_month', array(
        'label'     => 'Month',
        'type'      => 'varchar',
        'input'     => 'select',
        'source'    => 'eav/entity_attribute_source_table',
        'required'  => true,
        'position'  => 1,
        'option'    => array (
            'values' => array (
                'January',
                'February',
                'March',
                'April',
                'May',
                'June',
                'July',
                'August',
                'September',
                'October',
                'November',
                'December'
            )
        )
    ));
}
Run Code Online (Sandbox Code Playgroud)

Dmy*_*kin 9

据我所知,在addAttribute()通话中不可能直接这样做.但是您可以在下一个方法保存属性后设置商店标签:

$attributeId = $this->getAttributeId('customer', 'dob_month');
$attribute = Mage::getModel('eav/entity_attribute')->load($attributeId);
$attribute->setStoreLabels(array(store_id => 'Store label'))
    ->save();
Run Code Online (Sandbox Code Playgroud)

  • 另请注意,这不适用于默认(store id:0)商店视图.为此你需要像这样使用setFrontendLabel:`$ attribute-> setFrontendLabel('Test') - > setStoreLabels(array(1 =>'Test Again')) - > save();` (2认同)