1

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).

3
  • $category->getLevel() == 3 ? Jun 16, 2014 at 15:54
  • Thx . I was also thinking like that... but I'm New in magento where should i edit the code (in php file or else )
    – Bhavesh G
    Jun 16, 2014 at 15:56
  • I've added an answer to best suit your needs. Jun 16, 2014 at 16:05

1 Answer 1

1

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.

Your Answer

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

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