Magento: Include Toolbar And Pagination When Listing Products

Magento pagination toolbarMany people are having the issue where the toolbar and pagination doesn’t show when listing products on a CMS page and are continuously asking for help on the Magento forums but as far as I could see there is no solution posted there. In fact that’s the case for most questions posted on the forums.

How to show the toolbar and pagination when listing products on pages other than category pages is actually quite simple. In fact it’s very simple!

The problem:

You may be using something like the code below to insert new products on your home page:

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

Source: Magento: display new products on the home page

Or you may use this method (something like the code below) to display new products from a specific category:

{{block type=”catalog/product_list” category_id=”3″ name=”home.catalog.product.new” alias=”product_homepage” template=”catalog/product/featured.phtml”}}

Source: Magento: display new products on home page – by category!

But now you also want to include the toolbar and pagination. In Magento versions prior to 1.4, you could have used something like this:

{{block type="catalog/product_list" category_id="3" template="catalog/product/list.phtml"}}

Where the “category_id” is your category id.

In Magento 1.4, this method no longer works. The pagination and toolbar will NOT display because it is now handled in a different way.

The solution:

So here’s a simple way to display products on any CMS page and include the toolbar and pagination:

1. Go to CMS > Manage Pages and click on the page where you want to display your products.

2. Under the “Design” tab, insert the following code in the “Update Layout XML” field:

<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<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="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>

Make sure to change the category id to your own id. That’s it!

Related Posts:

Don’t forget – subscribe and follow!

Be sure to subscribe to the feed and follow us on Twitter for more tips, resources, and giveaways!

22 Comments

  • Magento
    Works perfectly!
  • simon
    Almost works perfectly but you still need to put some content in the content section of the CMS page as it will not allow blank content there.
  • Bui Phong
    Hello,

    Currently I’m using this code to render the toolbar html in a custom php file outside magento.

    $layout = Mage::getSingleton(‘core/layout’);
    $toolbar = $layout->createBlock(‘catalog/product_list_toolbar’);

    //Render toolbar html
    echo $toolbar->toHtml();

    It works perfectly on magento 1.3.2.4 but not on 1.4.1.0.
    In magento 1.4.1.0, the toolbar html is rendered without pager.

    Could you please tell me the code needs to be changed to make it work on
    1.4?

  • Fernando
    Hi! I’m very interest in doing the same thing but with the New products template. I’ve tried this code but It shows the products but without the grid or toolbars, pages, etc.

    I’m using a “New” CMS page with this Update Layout XML:

    empty6
    one_column5
    two_columns_left4
    two_columns_right4
    three_columns3
    product_list_toolbar

  • JJG
    If you format it this way:
    [code]

    product_list_toolbar

    [/code]

    you can insert this into the catalog.xml file in the Category Layered Navigation right below (line 120):
    [code]

    [/code]

    Works in 1.4.0.1

    Thanks for the help, the Magento forums were useless

    Noam -

    Hi JJG,

    The code didn’t go through – can you try again using code brackets like this: <code>code goes here</code>?

    Thanks!

  • vaatwasmachines
    Thanks for sharing this solutions. Many weeks searching for this problem and finally i can move on with my shop.

    Thnx again!

  • Ela
    Hi could any one find the solution for this..

    $layout = Mage::getSingleton(‘core/layout’);
    $toolbar = $layout->createBlock(‘catalog/product_list_toolbar’);

    //Render toolbar html
    echo $toolbar->toHtml();

    This is not working in 1.4.1 but worked in 1.3. I have to use pagination toolbar.

  • jeremys.awesome
    Nice post Noam! Very helpful.

    Also, found this post which shows how to do this with new products:
    http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination

  • espresso apparaat
    Thanks for this piece of code, works like a charm!
  • Elijah
    Good thing I found you on google, the magento forums have no answers yet. Thanks for posting this.
  • n00t
    Hi – great post! What if the pagination isn’t working on the regular products page? For some reason mine doesn’t work and I couldn’t find any answers in the Magento forum. Any help would be appreciated. Thanks!
  • Felipe Pontes
    Hi all.

    I want to implement a new product listing page with pagination in backend of Magento 1.4.1.1 but I can’t put that code to work.
    I’m using the following code in my layout file (design/adminhtml/default/default/layout/mymodule.xml):

    product_list_toolbar

    Where productResult is a block that extends from Mage_Catalog_Block_Product_List and mymodule/product/products.phtml is a copy of catalog/product/list.phtm; and paginationToolbar is a block that extends from Mage_Catalog_Block_Product_List_Toolbar and mymodule/paginationtoolbar.phtml is a copy of catalog/product/list/toolbar.phtml.

    Somebody knows how can I do that?

    Thanks in advance.
    Felipe Pontes

  • Felipe Pontes
    {{reference name=”content”}}
    {{block type=”mymodule/productResult” template=”mymodule/product/products.phtml” name=”product_list”}}
    {{block type=”mymodule/paginationToolbar” name=”product_list_toolbar” template=”mymodule/paginationtoolbar.phtml”}}
    {{block type=”page/html_pager” name=”product_list_toolbar_pager”/}}
    {{/block}}
    {{action method=”setToolbarBlockName”}}{{name}}product_list_toolbar{{/name}}{{/action}}
    {{/block}}
    {{/reference}}
  • Phil
    Thank you so much! Your XML solution was the missing piece of what I needed!
  • NashBridges
    I would like to thank you all. This really helped me, all magento forums and even blogs got it all wrong.

    With this finaly fixed, is there a way to display the actual date of the product being added in the “list” view?

  • Adrian Pironescu
    Nice snippet.
    Has someone found a solution how to display the toolbar with pager in magento 1.4 ?

    Thanks

  • shawkat alam
    nice and useful post………thanks
  • Juan
    Thanks 1000!!!! From SPAIN!!!!
    Works perfectly!!!
  • Rodrigo
    When I select a category under navigation bar, it shows the number of products defined, imagine is set to display 9 prodtucts per page; and I have 60 products in that category. Magento is just showing the first 9 items, and there’s no pagination, means costumers don’t have access to seeing other pages and products on other pages, unless I set it to view all products. Is that a way to put pagination on this pages as you did with CMS pages?!
    Thanks in advance
  • Zedas
    Hi

    Thanks, it saved my life :-)

  • Manish
    I have written a detailed blog post on this topic here
    http://www.excellencemagentoblog.com/magento-collection-paging

Leave a Reply

Sorry - this blog is now closed to new comments.