2

I have Category hierarchy as,

Root Category 
Category 1
    Category 1.1
        Category 1.1.1
        Category 1.1.2
        Category 1.1.3
    Category 1.2
        Category 1.2.1
        Category 1.2.2
        Category 1.2.3
    Category 1.3
Category 2
.       .       .
.       .       .
.       .       .

Question After Clicking first category (eg. Catergory 1). In left side layered Navigation, it dispays only it's sub category. Not sub's sub category.

Eg. I want this after Clicking Category 1 in layered navigation as,

Category 1.1
    Category 1.1.1
    Category 1.1.2
    Category 1.1.3

Category 1.2
    Category 1.2.1
    Category 1.2.2
    Category 1.2.3

Category 1.3
    Category 1.3.1
    Category 1.3.2
    Category 1.3.3

And after clicking Category 2,

Category 2.1
    Category 2.1.1
    Category 2.1.2
    Category 2.1.3

Category 2.2
    Category 2.2.1
    Category 2.2.2
    Category 2.2.3

Category 2.3
    Category 2.3.1
    Category 2.3.2
    Category 2.3.3

and so on ....

How can i achieve this .. please help .. Thank you..

1

This happens in the core Magento code. In the class Mage_Catalog_Model_Layer_Filter_Category when it gets all the categories to select it limits the categories to only direct children.

It starts with the function _getItemsData but the limitation happens in Mage_Catalog_Model_Resource_Category::getChildrenCategories when it filters all the categories by children ids.

$collection = $this->_getChildrenCategoriesBase($category);
$collection->addAttributeToFilter('is_active', 1)
    ->addIdFilter($category->getChildren())
    ->load();

Here the function $category->getChildren only returns direct children and not all children.

Try updating the code to use getAllChildren instead as this should recursively get the category ids.

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.