Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show pagination links for product list on a Magento CMS page

I created a CMS Page via the Magento Admin interface, and i put the following code in there:

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

This shows me products from the category with the id 3.

My magento is configured to display 9 products per page. In the category in question, there are 30 products.

While on my category pages, I can see a paginator, that does not happen on the CMS page. What am I doing wrong?

like image 579
raduken Avatar asked Sep 26 '11 12:09

raduken


2 Answers

I had this same problem of no pagination links on the default list of products on my home page.

It turned out that following the advice I had seen on many sites to get products on the home page (why this should be a complex task on an e-commerce app is beyond me ...) was not the best way to go.

To solve this problem I removed the code

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

from the page content and just put in <div></div> (so it would let me save the page).

Then I replaced the XML under the "Design" tab with the XML from the catalog.xml file that defines the pager block. Like this:

<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>
        <action method="setColumnCount"><columns>3</columns></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="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
        <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
</reference>

This gave me the pagination links I needed. Hope it helps you.

like image 149
David Perlman Avatar answered Nov 16 '22 19:11

David Perlman


<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" />

This needs to be added to the xml block where you are attempting to load product so that it gets the toolbar and the pager.

See this link as reference: Products with Pagination

like image 41
Vern Burton Avatar answered Nov 16 '22 20:11

Vern Burton