Get All Product Collection
<?php
$product_collection =
Mage::getModel('catalog/product')->getCollection()->setOrder('name',
'asc');
//getting the product collection, results are ordered by
product name
foreach($product_collection as $_product)
{
echo $_product->getId() . "<br />";
}
?>
Get Limitation product
<?php
$limit = 5;
$starting_from = 0;
$product_collection =
Mage::getModel('catalog/product')->getCollection()->setOrder('name',
'asc');
//getting the product collection, results are ordered by
product name
$product_collection->getSelect()->limit($limit,$starting_from);
//where $limit will be the number of results we want, $starting_from
will be the index of the result set to be considered as starting point
(note 0 is the index of first row)
//this will ouptput 5 records starting from 1rd record
foreach($product_collection as $_product)
{
echo $_product->getName().'<br/>';
echo $_product->getId() . "<br />";
}
?>
Get Latest Product Collection
<?php
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setOrder('created_at', 'desc')
->setPage(1, 5);
?>
<h2>Latest Products</h2>
<?php foreach($_productCollection as $_product) : ?>
<a href="<?php echo $_product->getProductUrl();
?>"><?php echo $_product->getName();
?></a></br>
<?php endforeach; ?>