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

  • $category->getLevel() == 3 ? – Julien Lachal Jun 16 '14 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 Gangani Jun 16 '14 at 15:56
  • I've added an answer to best suit your needs. – Julien Lachal Jun 16 '14 at 16:05
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.

|improve this answer|||||

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.