we have category called "shoes",
we gave discount for that category using promotions > catalog price rules

we have some 500 products in the category and now we are planning to delete the category and create an attribute and give discount for that attribute value.

using category using promotions > catalog price rules....

now we have to move all the products in that category to that attribute.

below @Marius gave solution, but i am missing somewhere

please help me to find my mistake....

2 Answers 2


First create the attribute and the values you need for it if it's a dropdown attribute. Then....

$categoryId = your category id here;
$category = Mage::getModel('catalog/category')->load($categoryId);
$ids = Mage::getModel('catalog/product')->getCollection()->addCategoryFilter($category)->getAllIds();
$attributeCode = 'your_attribute_code_here';
$attributeValue = 'the value of the attribute you want to set on all products';
    array($attributeCode => $attributeValue),
  • i will try now..... Commented Oct 9, 2015 at 13:04
  • Was just about to put together this same method! Nice one. Commented Oct 9, 2015 at 13:04
  • @Marius i copied this file to root of the site : pastebin.com/b2KbS4Mw clone.php, and i ran sitename.com/clone.php in browser, its giving blank page is there anything else i have to do, now i am running index management Commented Oct 9, 2015 at 13:19
  • 1
    check at least on product in the backend to see if it has the attribute set
    – Marius
    Commented Oct 9, 2015 at 13:28
  • yes, the attribute is in attribute set. Commented Oct 9, 2015 at 13:30

Create the new attribute, for example Clothing Type with an option of Shoes.

Then in Catalog->Manage Products select all the shoes and use the actions drop down to 'Update Attributes' and apply the attribute in bulk to those products.

You can't actually 'convert' a category into an attribute, but this method will add that attribute label to each of the products. After which you are free to delete the category if you wish.

  • ya, but the problem is that we have some 5000 products in a store, we dont know which and all products we assigned for shoes until we check manually by selecting shoe category and checking the products. Commented Oct 9, 2015 at 12:50
  • Sorry but what you're asking is actually possible (change a category into an attribute), my answer above is a solution to what you're looking for despite this. There is no way to make a category suddenly become an attribute. Are you looking instead to apply the attribute in bulk to all products in the category? Your question is a little confusing is all. Commented Oct 9, 2015 at 12:58

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.