Yes. We can programmatically change the set of product attributes. I prefer to create massaction in the product grid of the catalog to multiselect the product, and then select massaction for the products.
Creating massaction in grid.php
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection') ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) ->load() ->toOptionHash(); $this->getMassactionBlock()->addItem('changeattributeset', array( 'label'=> Mage::helper('catalog')->__('Change attribute set'), 'url' => $block->getUrl('*/*/changeattributeset', array('_current'=>true)), 'additional' => array( 'visibility' => array( 'name' => 'attribute_set', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('catalog')->__('Attribute Set'), 'values' => $sets ) ) ));
Create a controller action for change attribute sets for selected products.
public function changeattributesetAction() { $productIds = $this->getRequest()->getParam('product'); $storeId = (int)$this->getRequest()->getParam('store', 0); if (!is_array($productIds)) { $this->_getSession()->addError($this->__('Please select product(s)')); } else { try { foreach ($productIds as $productId) { $product = Mage::getSingleton('catalog/product') ->unsetData() ->setStoreId($storeId) ->load($productId) ->setAttributeSetId($this->getRequest()->getParam('attribute_set')) ->setIsMassupdate(true) ->save(); } Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=>$productIds)); $this->_getSession()->addSuccess( $this->__('Total of %d record(s) were successfully updated', count($productIds)) ); } catch (Exception $e) { $this->_getSession()->addException($e, $e->getMessage()); } } $this->_redirect('adminhtml/catalog_product/index/', array()); }
source share