Reputation: 159
I am trying to create attribute programmatically for all grouped products on my site. I am trying to create custom attribute set with group.
$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();
The problem is that attribute appears in all product types. But i need for grouped products only. What i am doing wrong ?
Upvotes: 2
Views: 268
Reputation: 1697
in your code $oEntitySetup have all products, you never take a specific group, and is sure you gift the new attribute to all products
Upvotes: 0
Reputation: 114
Assign created attribute to a particular "attribute set" and then while creating any group product - select this attribute set.
Upvotes: 2