9

Let's assume I have a category, Clothing and this category have a sub-category, T-shirts.

Now I add a product to the T-shirts category (by checking the box in the add product screen), but I don't check the Clothing category. So, I assumed this meant that the product would only appear in the T-shirts category on the front end, and not in the parent category Clothing.

However, the product appears in the Clothing and T-shirt categories.

This is a problem because the T-shirt category is an "Include in navigation menu" > No category, i.e. It is supposed to be hidden. All the products in the category have visibility of catalog, so they don't appear in search results.

I've investigated this quite deeply so far and have found that the problem is with the Magento catalog indexing. Running the Category Products indexer from System > Index Management rebuilds the index, running Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Indexer_Product::reindexAll().

This function SELECTs various data from several category-related tables and pipes it into the catalog_category_product_index table, which is the table used to generate the products collection for the category pages.

Does anyone have any suggestions as to how to hide/prevent products from sub-categories appearing in their parent categories?

I'm using Magento 1.4.1.0. The Clothing category is set to Anchor and the T-shirts category is not. Use flat category is set to yes.

12

This is actually a feature. If you want to avoid this you should set the flag 'Is anchor' to 'No' on the parent category. In your example 'Clothing'. This way, in the parent category you will see only products directly assigned to it.
After you do the changes you should re-index everything.

  • 2
    Ahh, but I need to keep "Is Anchor" on the parent category, because it uses Layered Navigation. – ProcessEight Jun 13 '13 at 15:14
  • Erm....then I think you have a problem. I'm out of ideas on this. – Marius Jun 13 '13 at 15:31
  • I don't need the layered navigation in the T-shirts category, so I think I'll move the T-shirts category out of Clothing, so it will only show directly related products as you say – ProcessEight Jun 13 '13 at 15:45
  • @sfrost2004 So, T-shirts are not clothing? I guess I've been using them wrong... – Benubird Sep 11 '13 at 14:14
  • 2
    hmmm I was looking @ stackoverflow.com/questions/22990622/… where I saw $this->_productLimitationFilters['category_is_anchor'] = 1; AND maybe something tlink this $this->getLoadedProductCollection()->addAttributeToFilter('is_parent', array('eq' => 1)) -- If it is a parent – snh_nl Aug 13 '15 at 12:53

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.