Reputation: 1495
I have found the following piece of code to remove a product from a category:
Mage::getSingleton('catalog/category_api')->removeProduct($category->getId(),$product->getId());
However I'm not sure how to use it! The product I wish to remove has id 13409
and the category id is 7
How do I get the above to work? I've tried the following but it doesn't work:
Mage::getSingleton('catalog/category_api')->removeProduct($category->7,$product->13409);
Upvotes: 1
Views: 3799
Reputation: 2843
To programatically remove a product from category, try this :
Mage::getSingleton('catalog/category_api')->removeProduct('7','13409');
You just need to pass the category_id
and the product_id
not the collection
Upvotes: 5