2

Mistakenly i imported products with irrelevant categories, how can i Bulk unchecked categories check box for selected products by csv or anything.

  • You want to uncheck or you want to assign correct category to the products? – Purushotam Sharma Mar 17 '17 at 6:02
  • @PurushotamSharma : uncheck – user51361 Mar 17 '17 at 6:03
1

use getCategoryIds and setCategoryIds property of product model

$product = Mage::getModel('catalog/product')->load($id);
$cat=$product->getCategoryIds();
//remove category id from $cat array
$product->setCategoryIds($cat); //set it again
$product->save();
  • I agree your point, but i need particular products category unchecked – user51361 Mar 17 '17 at 6:06
  • 100k products in my site, just 10k products categories mistakenly imported with various categories, so how can i unchecked, is it possible using CSV – user51361 Mar 17 '17 at 6:08
  • make array of that products and load collection then just remove that categories from product @Aveeva – Gopal Patel Mar 17 '17 at 6:08
  • Bro i don't want unchecked all categories, just unchecked selected products, is it possible using CSV – user51361 Mar 17 '17 at 6:11
  • how many such categories are there ? @Aveeva – Gopal Patel Mar 17 '17 at 6:12
1

I am giving short example you can use it your own way.

//first we will remove all products from category 
$category = Mage::getModel('catalog/category')->load(<Your_Category_ID>);
$category->setPostedProducts(array()); // this will remove all products from category. 
$category->save();

// now we will assign right product to category with below code 

$category = Mage::getModel('catalog/category')->load(<Your_Category_ID>);
$category->setPostedProducts(<here array of product id which you want to assign>); // this will remove all products from category. 
$category->save();

Hope it helps.

Thanks

  • I agree your point, but i need particular products category unchecked – user51361 Mar 17 '17 at 6:06
  • Yes prepare one list with right category and right product id then you can use above code so it will remove first all product from category and then assign it to correct category – Dhaval Solanki Mar 17 '17 at 6:07
  • 100k products in my site, just 10k products categories mistakenly imported with various categories, so how can i unchecked, is it possible using CSV – user51361 Mar 17 '17 at 6:08
  • Bro i don't want unchecked all categories, just unchecked selected products, is it possible using CSV – user51361 Mar 17 '17 at 6:09
  • I am using CSV to assign categories for my products. is possible to unchecked from using csv – user51361 Mar 17 '17 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy