Magento: Include Toolbar And Pagination When Listing Products
- Category: questions, web design, web development
Many 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:
- Magento: Pagination Disappears On The Search Result Pages After Upgrading to 1.4
- Upgrading To Magento 1.4
Don’t forget – subscribe and follow!
Be sure to subscribe to the feed and follow us on Twitter for more tips, resources, and giveaways!
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?
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
[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 - September 2nd, 2010
The code didn’t go through – can you try again using code brackets like this: <code>code goes here</code>?
Thanks!
Thnx again!
$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.
Also, found this post which shows how to do this with new products:
http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination
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
{{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}}
With this finaly fixed, is there a way to display the actual date of the product being added in the “list” view?
Has someone found a solution how to display the toolbar with pager in magento 1.4 ?
Thanks
Works perfectly!!!
Thanks in advance
Thanks, it saved my life
http://www.excellencemagentoblog.com/magento-collection-paging