Thursday 5 June 2014

Magento – display root category products with filters

I had to display all the child categories products of the root category on a page with filtered navigation on the left column, but by default Magento does not display the root category products.
After some search and research I find the solution for this. It can be accomplished using Layout Update XML inside the CMS page. Not only layered nav but toolbar will also be displayed. For this we need to create a new CMS page or we can use any existing page where we want to display the products of the root category with filtered nav.
Follow steps:
1. Open Manage Category page in admin and choose the root category you want to display. Make sure that the category is Active and Is Anchor yes. Note down the category id.
2. Create a new CMS page, CMS > Pages > Add New Page or Edit any existing one where you want to display the products.
3. Fill the proper information in the required fields.
4. Under Design tab, paste the given code in the Page Layout > Layout Update XML textarea.
5. In the code find “category_id 3 category_id” and change your category id with 3. For example your category id is “2″ so it should be “category_id 2 category_id“.
6. Select the Layout 1, 2 or 3 columns whatever you want.
7. Note: I used reference name=”left” so layered nav will display only if 2columns with left bar is selected. If you want the right side column than change reference name=”left” to reference name=”right”.


<reference name="content">
     <block type="catalog/product_list"  name="product_list" template="catalog/product/list.phtml">
        <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
            <block type="page/html_pager" name="product_list_toolbar_pager"/>
         </block>
         <action method="setCategoryId"><category_id>3</category_id></action>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
     </block>
 </reference>
<reference name="left">
    <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/> </reference> 
 
Save the page. Refresh cache and visit the page using the URL assigned in the CMS page .






2 comments:

  1. this code is not working can u have more solution
    when use code so page display blank

    ReplyDelete