Magento模块设置 - 将产品属性更改为不需要

Mar*_*ace 7 magento

如何在安装模块期间更改eav属性属性.

具体来说,我想将产品属性从需要更改为不需要.

我目前正在我的模块设置中的getDefaultEntities调用中合并更新的产品属性,但它给出了奇怪的结果.

例如:

public function getDefaultEntities()
    {        
        return array(
            'catalog_product' => array(
                'entity_attribute_collection' => 'catalog/product_attribute_collection',        
                'attribute_model' => 'catalog/resource_eav_attribute',
                'table' => 'catalog/product',
                'entity_model' => 'catalog/product',
                'additional_attribute_table' => 'catalog/eav_attribute',
                'attributes' => array(
                    'short_description' => array('required'=> false)
                )
            )
        );

    }
Run Code Online (Sandbox Code Playgroud)

short_description字段中的结果会丢失其前端标签

ben*_*rks 19

/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer->updateAttribute('catalog_product','short_description','is_required',0);
Run Code Online (Sandbox Code Playgroud)

  • 请注意,addAttribute()具有使用_prepareValues()的字段转换.但updateAttribute()确实*不*使用它.所以它在这里正确设置为'is_required',但是在addAttribute中,你使用'required'来做同样的事情. (3认同)