In this article we are covering the area of how to display products from a category in magento and this is as easy if you have basic knowledge in magento

you can just write the code given below in the template files and call the template like this in the editor of home page

You can create one in the app/design/frontend/default/your_template/template/catalog/product/new.html

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

<?php
$_helper = $this->helper('catalog/output');
$cat_id = 12; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$collection = $category->getProductCollection()->addCategoryFilter($category)->addAttributeToSelect('*');
$i=0;
if(!empty($collection))
{	
foreach ($collection as $_product): 
?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(53,64); ?>" alt="img"/>
</a>
<?php echo $_product->getName(); ?>
<?php echo Mage::helper('core')->;currency($product->;price) ?>
<?php  endforeach;
}else
{
  echo 'No products exists';
}               
?>

Hope it helps you to display products from a category in magento pages

Leave a Reply

Your email address will not be published.