0

I have created several attribute set which are based on Default attribute set.
Now when i make changes in the default attribute set its not getting reflected in the new attribute set which was created using 'Default' attribute set as base. Due to this i have to manually update each and every new attribute set.

Is there a way to overcome this. For example i have created a new attribute set called 'A' which is based on 'Default' attribute set. Now i have added a new attribute called 'customer_code' in the 'Default' attribute set. So when i check 'A', the new attribute 'customer_code' should come automatically since its based 'A' is based on 'Default'.
Thanks in advance.

0

This is the default behaviour in Magento.

If you add an attribute from backend you do not have any inheritance system.

What you can do is to add it programmatically from a script and program the inheritance logic by yourself.

Here you can find some additional info on how to createthem programmatically: http://inchoo.net/magento/programatically-create-attribute-in-magento-useful-for-the-on-the-fly-import-system/

0

You can try below code and modify it according to your need.
I wrote this installer script to create a custom attribute and assign it in all the attribute set.

// This installer scripts adds a product attribute to Magento programmatically.
// Set data:
$attributeName = 'Custom Attribute'; // Name of the attribute
$attributeCode = 'custom_attr'; // Code of the attribute
$attributeGroup = 'General';          // Group to add the attribute to
// Configuration:
$data = array(
    'type' => 'text', // Attribute type
    'input' => 'text', // Input type
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, // Attribute scope
    'required' => false, // Is this attribute required?
    'user_defined' => false,
    'searchable' => true,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => true,
    'unique' => false,
    'used_in_product_listing' => true,
    'apply_to' => 'grouped,configurable,bundle',
    'label' => $attributeName
);

// Create attribute:
// We create a new installer class here so we can also use this snippet in a non-EAV setup script.
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
$installer->startSetup();
$installer->addAttribute('catalog_product', $attributeCode, $data);

// Add the attribute to the attribute sets:
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($entityType->getId());

foreach ($collection as $attributeSet) {
    $attributeGroupId = $installer->getDefaultAttributeGroupId('catalog_product', $attributeSet->getId());
    $installer->addAttributeToSet('catalog_product', $attributeSet->getId(), $attributeGroupId, $attributeCode);
}

$installer->endSetup();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.