0

Is there was a way to programmatically clone an attribute set? I would like to create a new attribute set based on the DEFAULT set. I would like my cloned new attribute set to contain all the same groups and attributes that the Default set does.

I thought there was a way to quickly write a program to do this, but now I'm getting confused.

Please advise.

4
$entityTypeId      = Mage::getModel('catalog/product')->getResource()->getTypeId();
$baseAttributeSet  =  4; // "default" attribute set 
$model = Mage::getModel('eav/entity_attribute_set')
            ->setEntityTypeId($entityTypeId);
$model->setAttributeSetName('my_attr_set');
$model->validate();
$model->save();
$model->initFromSkeleton($baseAttributeSet);
$model->save();

Code extract from Mage_Adminhtml_Catalog_Product_SetController::saveAction()

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.