1

i have a shop with a lot of categories. Layered Navigation (shop by categories) is on and active.

Problem: I have two categories with plenty of subcategories. The Shop by Filter is now showing all subcategories (and their subcategories) of the category.

For these two categories it would be better, just showing the next-level-categories (and not their subcategories as well).

Example:

  • Cat 4 and Cat 5: Layered Navigation should only show direct subcategories of Cat 4 and 5.
  • All Other Categories should show all Subcategories (all Levels).

I hope this makes it clear and anyone knows a solution.

Thanks for your help.

1 Answer 1

1

Ok,

I tried something wired:

Edited: app\design\frontend\MY-TEMPLATE\default\template\catalog\layer\filter.phtml as following.

<ol>
<?php $current_cat = Mage::registry('current_category') ?>
<?php $c_items = 2 ?>
<?php foreach ($this->getItems() as $_item): ?>
    <?php if (count($this->getItems()) > 20) $c_items = 1 ?>
    <?php $item_cat_id = $_item->getValueString() ?>
    <li>
        <?php if ($_item->getCount() > 0): ?>
            <?php $category_model = Mage::getModel('catalog/category');
            $_category = $category_model->load($item_cat_id); ?>
            <?php if (!is_null($_item->getFilter()->getCategory()) && $c_items === 1 && (!is_null($current_cat))): ?>
                <?php if ($_category->getParentCategory()->getId() === $current_cat->getId()): ?>
                    <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>">
                        <?php echo $_item->getLabel() ?>
                        <?php if ($this->shouldDisplayProductCount()): ?>
                            <span class="count">(<?php echo $_item->getCount() ?>)</span>
                        <?php endif; ?>
                    </a>
                <?php endif; ?>
            <?php else: ?>
                <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>">
                    <?php echo $_item->getLabel() ?>
                    <?php if ($this->shouldDisplayProductCount()): ?>
                        <span class="count">(<?php echo $_item->getCount() ?>)</span>
                    <?php endif; ?>
                </a>
            <?php endif; ?>
        <?php endif; ?>
    </li>
<?php endforeach ?>

This will do following:

  • Whenever the Layered Navigation has more than 20 Subcategories to show, it will only show the next-level-categories.

Maybe it's a little dirty, but I am new and I have to start somewhere :)

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.