2
我正尝试以编程方式为我网站上的所有分组产品创建属性。我正在尝试使用组创建自定义属性集。Magento。仅为分组产品创建属性
$oEntitySetup = $this;
$oEntitySetup->removeAttribute('catalog_product', 'grouped_base_price');
$skeletonID=$oEntitySetup->getAttributeSetId('catalog_product','Default');
$entityTypeId = Mage::getModel('catalog/product')
->getResource()
->getEntityType()
->getId(); //product entity type
$attributeSet = Mage::getModel('eav/entity_attribute_set')
->setEntityTypeId($entityTypeId)
->setAttributeSetName("oggy_attr_set");
$attributeSet->validate();
$attributeSet->save();
$attributeSet->initFromSkeleton($skeletonID)->save();
$data = array(
'attribute_set' => 'oggy_attr_set',
'group' => 'General',
'label' => 'Base Price',
'apply_to' => 'grouped',
'input' => 'text',
'visible' => true,
'visible_on_front' => true,
'required' => true,
'position' => 1,
'global' => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL',
'note' => "Default Price For Configurable Products"
);
$oEntitySetup->addAttribute('catalog_product', 'grouped_base_price', $data);
$oEntitySetup->endSetup();
问题是该属性出现在所有产品类型中。但我只需要分组产品。我做错了什么?
您好,感谢您的回答。我已更新我的问题,请检查它。 – user3162709