3

i would like to show my news products in a page accessible from the menu.. the version of my magento is 1.7.0.2

so i created a page named "news". in tab design, i added this xml in the textarea (xml update layout):

'<reference name="content"><block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml">
  <action method="setCategoryId"><category_id>10</category_id></action>
  <action method="setColumnCount"><column_count>6</column_count></action>
  <action method="setProductsCount"><count>0</count></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" />
     <action method="setDefaultGridPerPage"><limit>12</limit></action>
     <action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
     <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
     <action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
     <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
     <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
  </block>
  <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
  <action method="setToolbarBlockName"><name>product_list_toolbar</name></action></block></reference>'

indeed i follow this tutorial : http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination/.

the problem is that this solution does not work.

On internet there are many solution to display them on the home page but not in a category page.

Thank you for all your help

  • Do you want to create a separate page or do you want your news products to display in a category page? – Shivani Feb 8 '16 at 6:24
1

Below are the steps I have taken to display New Products in a Category Page:

Step 1: Create products with the 2 attributes filled in as below in the screenshot:

enter image description here

Step 2: Create a category under Catalog > Manage Categories. Navigate to the tab Custom Design and do as per the screenshot:

enter image description here

Custom Layout XML code as follows (Update list.phtml to new.phtml):

<reference name="content">
   <block type="catalog/product_new" name="product_new" template="catalog/product/new.phtml">
      <action method="setCategoryId"><category_id>10</category_id></action>
      <action method="setColumnCount"><column_count>6</column_count></action>
      <action method="setProductsCount"><count>0</count></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" />
         <action method="setDefaultGridPerPage"><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
         <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
       </block>
       <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
</reference>

Step 3: Navigate from the Top Menu to the Category Page and see the below screenshot:

enter image description here

Couple of points about New Products in Magento:

  1. Default Products Count = 10, which you can override and edit the PHP itself or specify via XML (you will need to check how this is done).

  2. For the pagination to work, you can use catalog/product_list_toolbar, but this will call the list.phtml content There are no products matching the selection., which you might want to edit by creating a separate toolbar for New Products for ex: catalog/product_new_toolbar

Let me know if this helps.

Happy Coding...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.