We have a category structure like this:
Root
— Category 1
—- Category 1 – 1
——- Category 1 – 1 – 1
——- Category 1 – 1 – 2
—- Category 1 – 2
— Category 2
—- Category 2 – 1
—- Category 2 – 2
Normally, when a user clicks the root category, it appears as empty. Also Category 1 and 2 are empty (by mistake, it could be, that 1 or 2 products are there).
I want, that when a category is clicked, the products of all subcategories (and subcategories’ subcategories) are shown (+ the products which are in the category itself).
We cannot use is_anchor, as this behaviour is only for one of three storeviews and is_anchor is global.
My idea would be to rewrite Mage_Catalog_Block_Product_List, so it returns subcategories’ products when requesting a category but isn’t there a simpler approach by adding a filter or so to all category-collection-requests?
Answers to similar questions are incomplete or use is_anchor.
I solved the problem now on my own.
I created a module which rewrites
Mage_Catalog_Model_Category::getProductCollection()The steps are as follows:
parent::getProductCollection()is_active.->addAttributeToFilter('entity_id', array('in' => array_unique($result)));