3

If I search for a specific rug collection in my store, the category attribute will show and only have "rug" as an option, same with collection attribute, only one value shown (as it should). This IMO is pointless for the customer and doesn't need to be shown.

Is there an easy way to hide the layered navigation results if there is only one value present?

1 Answer 1

1

Not sure if you have solved the issue yet, still, assuming you want to hide the layered navigation block for filters where there is only one filter to be shown.

In a stock Magento installation, at file location app/design/frontend/base/default/template/catalog/layer/view.phtml file, you have this block of code :

<dl id="narrow-by-list">
    <?php $_filters = $this->getFilters() ?>
    <?php foreach ($_filters as $_filter): ?>
        <?php if($_filter->getItemsCount()): ?>
            <dt><?php echo $this->__($_filter->getName()) ?></dt>
            <dd><?php echo $_filter->getHtml() ?></dd>
        <?php endif; ?>
    <?php endforeach; ?>
</dl>

You'll need to have that file in your theme folder, and the place where it is checking for 0 results, you can simply chnage it to check for atleast 2 results. So the code will become :

<dl id="narrow-by-list">
    <?php $_filters = $this->getFilters() ?>
    <?php foreach ($_filters as $_filter): ?>
    <?php if($_filter->getItemsCount() > 1): ?>
        <dt><?php echo $this->__($_filter->getName()) ?></dt>
        <dd><?php echo $_filter->getHtml() ?></dd>
    <?php endif; ?>
    <?php endforeach; ?>
</dl>

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.