Your Ad Here

Monday, October 17, 2011

How To - Display products on home page

There are numerous ways to put products on your home page, and we’ll compile a list of code snippets you can use on your own store here. Some examples are outdated, they don’t work in magento 1.4.1 but solutions are provided at the bottom.

New products

Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show products labeled as “new” on your front page:
  1. {{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
(Note that you must have some new products in your catalogue for anything to show when you do this. In this context new doesn’t mean that you’ve recently added them; only products explicitly marked as new using ‘Set Product as New from Date’ and ‘Set Product as New to Date’ options in the ‘General’ product information page in the admin tool will be shown.)

All Products

Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show all products in your catalog on your front page:
  1. {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

All Products from one Category

Go to “CMS - Manage Pages” and select “Home Page” from the list of pages.
Use this code snippet to show one category on your front page:
  1. {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
The category ID can be found when you go to “manage category” and then select the category you want. The ID is written in the header.
Examples are outdated, dosent work in magento 1.4.1

Layout Update XML for magento 1.4

Because in 1.4 version Layout update is different than in 1.3 version, you can use this example:
  1. <reference name="content">
  2.     <block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
  3.         <action method="setCategoryId"><category_id>[category id here]</category_id></action>
  4.     </block>
  5. </reference>
Note: source taken from BrightEyesDavid’s post
It’s possible to add the ‘Root category’ ID here to show all products (Is Anchor Yes required!)

New products - Layout Update XML for magento 1.4

To display new product / latest product, you can use this following XML code in layout xml file or layout display in backend. You can use also the widgets to display the products. The code below has been inspired by the widget.
diglin
  1. <reference name="content">
  2.     <block type="catalog/product_new" template="catalog/product/new.phtml">
  3.         <action method="setProductsCount"><count>5</count></action>
  4.         <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
  5.         <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
  6.         <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
  7.         <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
  8.         <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
  9.     </block>
  10. </reference>

New products with pagination - Layout Update XML for Magento 1.4.1

By default the Magento New.php and New.phtml block and template do not provide a way for you to display new products with pagination. The pagination and toolbar elements of Magento belong to the Mage_Catalog_Block_Product_List class. It is possible for one to overwrite the New.php file that Magento provides so that it extends the


For more detail or step by step detail click here

No comments:

Post a Comment