Add the layered navigation in the product page.
In Magento the layered navigation appears on the category page but by including the below code we can layered navigation in the product page also.
You need to follow the steps below to accomplish the above task.
Step1:
Add a new phtml file in the folder location
app -> design -> frontend -> package -> theme-> template->
Inside the template of your theme search for ‘catalog\layer’ and create a layerview. phtml.
Step2:
Add the following code:
<?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; ?>
So the above code will help to create the layered navigation in the product page.
Step3:
Now move to the theme\layout folder and find the file catalog.xml where you can specify the position where the layered navigation will appear.
Add the following code:
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/ layeredview.phtml "/> under the following <label>Catalog Category (Anchor)</label>
Finally can access your Magento store frontend to see the layered navigation.