1

Is there any way to assign products to a category that are not assigned to any category? I have around 1000 products that are not assigned to any category so I would like to assign them to one single category.

1
  • make a new category and add the products there in the products tab.
    – Waseem
    May 19 '14 at 4:56
1

Try this.

  1. Write an external script to achieve this.
  2. In the script put the following code and make sure to put your category id instead what there is.

    $category_id = 8; 
    
    // Get all the product collection.
    $collection = Mage::getModel('catalog/product')->getCollection();
    foreach($collection as $product) {
        // Get categories of product.
        $cats = $product->getCategoryIds();
    
        // If this product doesn't have categories.
        if(count($cats) == 0) {
            // Set the category id and save.
            $product->setCategoryIds(array($category_id));
            $product->save();
        }
    }
    
0

Your Answer

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

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