Magento - Layered navigation on product pages

20 Jul 2010
To attract more potential customers to your online store, you must create an ease for them when browsing products they need. In Magento, Layered Navigation is a useful feature that allows customers to find item according to two default properties: Price and Categories.

However, as you know, Layered Navigation basically can work only on category page. Now, I will share you how to make it work on product pages, too.
Just follow these steps:

Step 1:
In folder \app\design\frontend\default\your theme\template\catalog\layer, create 1 layeredview.phtml file

Step 2:
Copy the following code into layeredview.phtml file:
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if($this->canShowOptions()): ?>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__('Shop by ') ?><?php echo $this->__($_filter-
>getName()) ?></dt>
<?php $url= $this->helper('core/url')-
>getCurrentUrl();?>
<?php
//$re_url=$_category;
//temporary hard coded
$re_url='/bbbcshop/index.php/products.html';
?>
<dd>
<?php echo
str_replace(array($url.'?',$url.'/?'),array($re_url.'?','/'.$re_url.'?'),$_filter->getHtml()) ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>

Step 3 :
Go to app\design\frontend\default\your theme\layout\catalog.xml
And find this line of code:
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
Then put right under it the following code:
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/ layeredview.phtml "/>
If Layered Navigation is on the right side, then you write <reference name="right">

If you have any further problem please email us at: [email protected]

Related Posts

Upgrade magento theme from 1.4.0.1 to 1.4.1.0

Upgrade magento theme from 1.4.0.1 to 1.4.1.0

16 Jul 2010
Finally, Magento version 1.4.1.0 has been released, and much improved since 1.4.0.1. Here is the tip for fixing common theme issue while upgrading.