Parent category is showing products in subcategories, even though product was not assigned to parent category

magento.stackexchange https://magento.stackexchange.com/questions/4736

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top