2013-09-25 36 views
0

我已經成功創建了自定義產品類型(測試)。現在我已經按照以下方式爲目錄部分添加了一個屬性。產品類型未針對magento中的custum屬性進行更新

$installer = $this; 

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 

$installer->startSetup(); 

$data=array(
'type'=>'decimal', 

'input'=>'text', 

'label'=>'Rent Price', 

'global'=>Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 

'is_required'=>'0', 

'is_comparable'=>'0', 

'is_searchable'=>'0', 

'is_unique'=>'0', 

'is_configurable'=>'0', 

'use_defined'=>'0', 

'apply_to' => array('test') 
); 

$attributeId = $setup->addAttribute('catalog_product','custum_price',$data); 

,任何東西都可以正常使用,但該屬性顯示在每一個products.I剛纔檢查的表結構,發現「catalog_eav_attribute」表正在針對此attribute.When我編輯在apply_to場「空」手動設置此字段的值並設置值「test」,屬性開始在測試類型產品中顯示。 但我不想以這種方式更新。請指導我我做錯了什麼。

+0

我找到了solution.check這個http://stackoverflow.com/questions/12051305/adding-attributes-to-custom-product-only?rq=1 – mjdevloper

回答

0

爲什麼你使用屬性類型,而不是使用屬性集。僅將屬性添加到所需的屬性集。使用屬性集和其他產品創建產品將不會顯示此屬性。檢查magento屬性集,如果你正面臨一些問題

+0

親愛的我沒有設置屬性類型,但我可以通過以下行設置屬性設置:$ attributeId = $ setup-> getAttribute('catalog_product','custum_price'); $ attributeSetId = $ setup-> getAttributeSetId('catalog_product','Default'); $ attributeGroupId = $ setup-> getAttributeGroup('catalog_product',$ attributeSetId,'Prices'); $ setup-> addAttributeToSet('catalog_product',$ attributeSetId,$ attributeGroupId ['attribute_group_id'],$ attributeId ['attribute_id']);但我只想爲custum產品類型顯示此選項。 – mjdevloper

+0

如果您可以設置屬性設置屬性,爲什麼您不使用屬性集爲您的自定義產品類型。爲後端產品顯示的屬性數量是從屬性集合派生的。所以,請嘗試使用它 – Sandeep

相關問題