cancel
Showing results for 
Search instead for 
Did you mean: 

Categroies Move

SOLVED

Categroies Move

Hello,

 

i have the following problem:

My category structure is:

Default Category

     - Reithosen

     - Stiefel

     - Herrenbekleidung

     .... and many more

 

Now i have a lot of Categories on my Startpage (http://www.pot-planet.de)

I want to add just 5 or 6 Categories and order the other categories as subcategories.

Now when i add a new categorie (Reiter) and add the category "Stiefel" to that category on my startpage is a drop down visible.

Now my structure is like this:

Default category

     - Reiter

          -Stiefel

 

But when i now open the link "Stiefel" in my dropdown menu there come a message: There are no products matching the selection.

 

When i now go into a product from the category "Stiefel" and open the Tab "categories" i see that "Default Category" and "Reiter" are not checked. So i must manually make a check mark and save it. Now i find the product. 

But i cant do that with all products thats to much work. I have 870 Products... 

Know anyone what i can do that magento know that the Main Category must be checked too?

 

Best regards

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Categroies Move

Here is how you can assign multiple products to a category and merge with the existing products.

The example is for one category but you can turn it into a loop to make it work for more.

$categoryId = 6;
$category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
//get the current products
$products = $category->getProductsPosition();
//now attach the other products.
$newProductIds = array(1,2,3,4,5);
foreach ($newProductIds as $id){
	$products[$id] = 1;//you can put any other position number instead of 1.
}
//attach all the products to the category
$category->setPostedProducts($products);
//save the category.
$category->save();

If you want an even faster way of doing it you can do direct inserts in the table catalog_category_product.

Just make sure you reindex when you are done.

OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions

View solution in original post

3 REPLIES 3

Re: Categroies Move

It's kind of hard to understand what's your problem, but I guess it has something to do with categories not displaying products of subcategories. To achieve it use "Is Anchor" functionality under category Display Settings tab.

Tanel Raja

Re: Categroies Move

Here is how you can assign multiple products to a category and merge with the existing products.

The example is for one category but you can turn it into a loop to make it work for more.

$categoryId = 6;
$category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
//get the current products
$products = $category->getProductsPosition();
//now attach the other products.
$newProductIds = array(1,2,3,4,5);
foreach ($newProductIds as $id){
	$products[$id] = 1;//you can put any other position number instead of 1.
}
//attach all the products to the category
$category->setPostedProducts($products);
//save the category.
$category->save();

If you want an even faster way of doing it you can do direct inserts in the table catalog_category_product.

Just make sure you reindex when you are done.

OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions

Re: Categroies Move

ty nice solution