2

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?

1

2 Answers 2

5

To do the same from phtml file, use:

 <?php echo $this->getLayout()->createBlock("catalog/product_list") ->setCategoryId(4)->setTemplate("catalog/product/list.phtml")->toHtml();?> 
Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.