1

I am adding products from web services for my Magento store.Problem is web services keep changing product attribute set with an interval of few days. I came to know that Attribute Set cannot be changed after a product has been created. So what is the possible way to update the product attribute set? Shall i delete the product and recreate the same product or change the attribute set from database. Which one will be better? If i delete the product will it effect on order/inventory section?

I have already checked by updating attribute set from database.It works fine.For testing purpose I have updated the product which has default attribute set. But i want to update those attribute set that has one custom group containing 10 different attributes.

0

1 Answer 1

4

You can use or analyse code of below free module to change attribute set of a product :

http://www.magentocommerce.com/magento-connect/flagbit-change-attribute-set.html

The code I found from module which can change attribute set :
This code is located in /app/code/community/Flagbit/ChangeAttributeSet/controllers/Adminhtml/Catalog/ProductController.php

foreach ($productIds as $productId) {
    $product = Mage::getSingleton('catalog/product')
           ->unsetData()
           ->setStoreId($storeId)
           ->load($productId)
           ->setAttributeSetId($attributeSetId)
           ->setIsMassupdate(true)
           ->save();
}

You should pass below to this code :

  • product ids ($productIds)
  • store id ($storeId)
  • attribute set id ($attributeSetId)
3
  • Will it unset all the Data of particular product? unsetData() what it will do? Commented Aug 2, 2013 at 11:28
  • No it will not unset any product data..it will unset object data on which it is called (in this case it is of Mage_Catalog_Model_Product class)
    – Ravinder
    Commented Aug 9, 2013 at 10:42
  • UPDATE catalog_product_entity SET attribute_set_id = '9' WHERE catalog_product_entity.entity_id = 15; this one help you.
    – zus
    Commented Nov 17, 2017 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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