How to Display Products on Front Page of Specific Category

categoryproduct

I have a homepage.phtml which will create a block by calling a new.phtml

homepage.phtml

<div class="home-page-new-product">
    <p class="new-product-title"><?php echo $this->__('New Product') ?></p>
    <?php echo $this->getLayout()->createBlock("catalog/product_new")->setTemplate("catalog/product/new.phtml")->toHtml() ?>
</div>

first line of new.phtml

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
..

The question is how can I display products of specific category, is it possible to simply adjust the code of new.phtml only?

Best Answer

The block type catalog/product_new does not allow you to specify a category id. You could try using the catalog/product_list block instead which does allow setting a category id.

echo $this->getLayout()->createBlock("catalog/product_list")->setTemplate("catalog/product/list.phtml")->setCategoryId('category_id')->toHtml();
Related Topic