Magento – Hide Layered Navigation Attribute if Only One Available

attributeslayered-navigation

My store has numerous attributes in my layered navigation to allow customers to refine the product views/searches. On some of my categories i only have 1 attribute present.
For example one of my categories – women > accessories > belts

has:

- 1 price option ($10.00 and above)
- 3 colour options (brown, tan, black)
- 1 brand option (Levi's)

How can I hide any filters that only have 1 value present. So in this case instead of the above i would only want:

- 3 colour options (brown, tan, black)

to show in the layered navigation

Best Answer

edit the file /app/design/frontend/{package}/{theme}/template/catalog/layer/view.phtml and replace this line:

 <?php if($_filter->getItemsCount()): ?>  

with

 <?php if($_filter->getItemsCount() > 1): ?>

I only see one problem with this approach.
If all your filters have only one option they you will still get the section title

<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>

But this can easily be overcome if you loop through the available filters and see if you have at least one that has the items count bigger than 1.

Related Topic