Magento: Get Best Selling products

This article will show you how to get best selling products in your Magento store on the frontpage or anywhere else in your store.

<?php
   $productCount = 10;

    $storeId    = Mage::app()->getStore()->getId();      
     
    // get most viewed products 
    $products = Mage::getResourceModel('reports/product_collection')
                    ->addAttributeToSelect('*')     
                    ->addOrderedQty()
                    ->setStoreId($storeId)
                    ->addStoreFilter($storeId)                  
                    ->setOrder('ordered_qty', 'desc')
                    ->setPageSize($productCount);
  ?>   
    

Note:- The above code will only return array of most viewed products, just manipulate array in your design.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s