Thursday, 3 December 2015

Get recently added product in Magento

 <?php
$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getResourceModel('reports/product_collection')
                ->addAttributeToSelect('*')
                ->setVisibility(array(2,3,4))                
                ->setOrder('created_at', 'desc')
                ->setPageSize(10);
$count = $_productCollection->count();
?>

    <div class="item active">
    <?php
        $i=0;
        $flag=false;
        foreach($_productCollection as $product)
        {
            if($i<3)
            {
            ?>
         <a href="#">
                        <img src="<?php echo $product->getImageUrl();?>" alt="PHPCluster">
                    </a>
              <h3><a href="<?php echo $product->getUrlPath();?>"> <?php echo $product->getName();?></a></h3>
            <?php
$i++;
            } } ?>
</div>    

No comments:

Post a Comment