2

My store has the following categories:

- Root
     - other category
     - another category
     - Home
         - Kitchen
             - Cabinets
             - Appliances
             - Accessories
         - Bedroom
             - Storages
             - Beds
             - Blinds
         - Bathroom
             - Fittings
             - Tiles
             - Flooring
         - Lounge
             - Seating
             - Electricals
             - Lighting

In a custom module i have a page which loads a collection of all my level 4 categories through the home category path like so:

public function __construct()
{
    parent::__construct();
    $home_id = 52;
    $root_id = Mage::app()->getStore()->getRootCategoryId();
    $path = '1/'.$root_id.'/'.$home_id.'/';

    $collection = Mage::getModel('catalog/category')->getCollection()
    ->addAttributeToFilter('level', 4)
    ->addAttributeToFilter('is_active', 1)
    ->addPathsFilter($path)
    ->addAttributeToSelect(array('name'))
    ->addNameToResult()
    ->addUrlRewriteToResult()
    ->setLoadProductCount(true);
    $this->setCollection($collection);

}

So the above successfully gets these categories in a collection:

             - Cabinets
             - Appliances
             - Accessories
             - Storages
             - Beds
             - Blinds
             - Fittings
             - Tiles
             - Flooring
             - Seating
             - Electricals
             - Lighting

Now i need to be able to filter these categories by their attributes - in the same way the layered navigation works on products. The filtering needs to be done on the categories themselves not the products within.

For one example all these categories have a custom attribute of section. Only Lighting and Blinds have

section: lower

All the other categories have

section: upper

Is it possible to add layered navigation into the left sidebar so i can filter the categories by section (and others)?

1 Answer 1

0

For products Magento creates an index for the products/attributes values and then uses this index to build layered navigation.

For the custom module you can create similar index or calculate links on the fly, but none of the Magento default widgets can be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.