Magento – magento attributes filter only in last (level 3) category

attributeslayered-navigationnavigationproduct-attribute

I have category hierarchy up to level 3. ex,

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
While browsing categories in layered navigation, the product's attribute's filters are displaying in all layers but i want to attribute filter in only last category (eg. 3rd level category). How to do that

Note: I have searched it a lot but on one question of magento meta, one answer was altering css to hide filters in particular page. but i want to do it on higher level ( without css and if possible then php hacks).

Best Answer

In your_theme/template/catalog/layer/filter/filter.phtml edit the code as follows:

<?php if(Mage::registry('current_category')->getLevel() == 3): ?>
    <ol>
    <?php foreach ($this->getItems() as $_item): ?>
        <li>
            <?php if ($_item->getCount() > 0): ?>
            <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            <?php if ($this->shouldDisplayProductCount()): ?>
            (<?php echo $_item->getCount() ?>)
            <?php endif; ?>
        </li>
    <?php endforeach ?>
    </ol>
<?php endif; ?>

Hope this helps.

Related Topic