0
我已經使用自定義模塊的安裝腳本創建了一個屬性。一個屬性是一個下拉菜單,它只有兩個選項,分別是'是','否'。另一個屬性是文本字段。我需要通過此腳本設置默認值。我捆綁了以下內容。但沒有奏效。如何通過安裝腳本爲屬性設置默認值?
$th = new Mage_Catalog_Model_Resource_Setup();
$th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'credit', array(
'group' => 'Prices',
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Credit rewards',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 'kkkkkkkk', // this is default value. but is's not setting
'searchable' => false,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple',
));
任何建議將不勝感激。先謝謝了。
我可以使用$安裝=新Mage_Catalog_Model_Resource_Setup(); – Sukeshini
你可以使用上面的答案作爲更新,如果不工作,你可以從這篇文章也參考:http://stackoverflow.com/questions/9599262/magento-add-new-attribute-to-all-products –
謝謝許多。它是當我添加一個新產品時。 – Sukeshini