zubair
zubair

Reputation: 33

display multiple category product on magento homepage

Recently I have installed the following theme on my magento site.

http://www.pagayo.com/manuals/theme-electronics-online-pt001/#theme-installation

As per the installation guide, there is only one way to show the products on homepage which is below

<reference name="content">

<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">

<action method="setCategoryId"><category_id>***</category_id></action>

<action method="setColumnCount"><count>5</count></action>

</block>

</reference>

Now, I don't want to show products from one specific category, I want to show products from other categories as well.

Please guide me how I can edit the above code in order to show multiple category products on magento homepage.

Upvotes: 0

Views: 5593

Answers (2)

Rajeev K Tomy
Rajeev K Tomy

Reputation: 2214

The easy way to display multiple list of products based on category is shown below

<reference name="content">
    <block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
        <action method="setCategoryId"><category_id>13</category_id></action>
        <action method="setColumnCount"><count>2</count></action>
    </block>
    <block type="catalog/product_list" name="featured2" template="catalog/product/list.phtml">
        <action method="setCategoryId"><category_id>10</category_id></action>
       <action method="setColumnCount"><count>2</count></action>
    </block>
 </reference>

You should add this code inside layout section of your home page. However this is messy. If you need to avoid toolbars and all other unwanted things as you desire, you probably want to use below code

 <reference name="content">
    <block type="catalog/product_list" name="featured" template="catalog/product/list1.phtml">
        <action method="setCategoryId"><category_id>13</category_id></action>
        <action method="setColumnCount"><count>2</count></action>
    </block>
    <block type="catalog/product_list" name="featured2" template="catalog/product/list2.phtml">
        <action method="setCategoryId"><category_id>10</category_id></action>
       <action method="setColumnCount"><count>2</count></action>
    </block>
 </reference>

As you can see, for each block I have set different list templates. So what you need to do is copy the original list template content in app/design/frontend/<your_package>/<your_theme>/catalog/product/list.phtml and paste it into our custom list templates. According to the path given above, you need to create multiple list template in app/design/frontend/<your_package>/<your_theme>/catalog/product/ directory with name list1.phtml, list2.phtml etc. Then edit each individual list file corresponding to a category according to your need. Make changes to those individual list templates. This will keep your core list.phtml untouched and make your site good in view.

Just play with it. Its awesome. Thanks.

Upvotes: 3

Krishna Sunuwar
Krishna Sunuwar

Reputation: 2945

There is multiple way to show product in home page. The one given in your theme guide (which you trying to use) is layout update method.

You can place product in home page:

  1. Layouy update method
  2. CMS Block method

As you already know to where to make changes to show productes (Admin -> CMS -> Home page)

For example to show list of nee products place following code in content of your CMS:

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

To show all products in home page

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

For detail guide see Magento Wiki "How To - Display products on home page" http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

P.s. If you want use theme xml, remove action node, the part.

Upvotes: 1

Related Questions