francesco.venica
francesco.venica

Reputation: 1721

Magento - product list into CMS page

I want to show a category product in a CMS page. For that process I have to insert the product list of a particular category inside a CMS page, to do it from backend I add a static block like this

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

How can I do the same thing inside phtml?

Upvotes: 2

Views: 10655

Answers (2)

Mohit Kumar Arora
Mohit Kumar Arora

Reputation: 2214

To do the same from phtml file, use:

   <?php echo $this->getLayout()->createBlock("catalog/product_list")
->setCategoryId(4)->setTemplate("catalog/product/list.phtml")->toHtml();?>

Upvotes: 5

IamManish
IamManish

Reputation: 160

This can be easily achieved through xml

<reference name="content">
    <block type="catalog/product_list" name="home" template="catalog/product/list.phtml">

            <!-- Product List View -->
            <action method="setCategoryId"><category_id>40</category_id></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="setToolbarBlockName"><name>product_list_toolbar</name></action>

    </block>

Just replace category id with your category id.

Upvotes: 3

Related Questions