Magento - Layered navigation on product pages

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
