শুক্রবার, ১৮ মে, ২০১২

Get Magento Bestsellers Products list

sometimes we need to show bestselling products. here is a piece of code to get magento bestselling products easily

<?php
    $collection = Mage::getResourceModel('sales/report_bestsellers_collection')
                         ->setModel('catalog/product')
                         ->addStoreFilter(Mage::app()->getStore()->getId())//if you want the bestsellers for a specific store view. if you want global values remove this
                         ->setPageSize(5)//se there the number of products you want returned
                         ->setCurPage(1);
     foreach ($collection as $_product){
      $realProduct = Mage::getModel('catalog/product')->load($_product->getProductId());
      //do something with $realProduct;
     }
?>

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন