开发者

Show pagination links for product list on a Magento CMS page

开发者 https://www.devze.com 2023-04-07 08:38 出处:网络
I created a CMS Page via the Magento Admin int开发者_JAVA技巧erface, and i put the following code in there:

I created a CMS Page via the Magento Admin int开发者_JAVA技巧erface, 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?


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.


<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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号