2012-05-02 49 views
7

如何在安裝模塊期間更改eav屬性屬性。Magento模塊設置 - 將產品屬性更改爲不需要

具體而言,我想將產品屬性從需要更改爲不需要。

我目前正在合併我的模塊設置中的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) 
       ) 
      ) 
     ); 

    } 

結果在SHORT_DESCRIPTION字段失去其前端標籤

回答

18
/* @var $installer Mage_Catalog_Model_Resource_Setup */ 
$installer->updateAttribute('catalog_product','short_description','is_required',0); 
+2

注意的addAttribute()具有使用_prepareValues場轉換()。但updateAttribute()不*使用這個。所以它在這裏被正確設置爲'is_required',但是在addAttribute中,你可以使用'required'作爲同一件事。 – Melvyn

相關問題