PHP Magento Tips

Powered by Blogger.

Magento get Most Viewed Products and best selling products List

Rate this posting:

Magento get best selling products Collection:

Mage::getResourceModel(‘reports/product_collection’) is used to get the most ordered (Best Selling) items on the basis of ordered quantities.

$storeId    = Mage::app()->getStore()->getId();

$productsCollection = Mage::getResourceModel('reports/product_collection')




            ->setOrder('ordered_qty', 'desc')//This tells the most ordered products




foreach($productsCollection as $product){

        $productIds[] = $product->getId();


The above example will give you the top 10 most selling products in Magento. You can add your own filter and page size to get the collection of the product.

Magento get Most Viewed Products:

Mage::getResourceModel(‘reports/product_collection’)->addViewsCount() Collection is used to get the most viewed items.

$mostViewedProd = Mage::getResourceModel('reports/product_collection')



$productIds = array();

foreach ($mostViewedProd as $product) {

   $productIds[] = $product->getId();


The above example will give you top 10 most viewed products.

The most interesting part in this query is its get data from 'report_event' table whose event_type_id=1 make INNER JOIN with 'catalog_product_entity' table whose entity_type_id = 4

You can check different type of event_type_id and entity_type_id from below screenshot.

report_event_type Table

eav_entity_type Table

Tag : Magento
5 Comments On "Magento get Most Viewed Products and best selling products List"

The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
ecommerce website development company | ECommerce Development Company in Bangalore|Ecommerce Website Design and Development Company in Bangalore | Magento Development Company

Thanks for the best was very useful for me.keep sharing such ideas in the future as well.this was actually what i was looking for,and i am glad to came here!
magento development company in bangalore 

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Typo3, kindly contact us
MaxMunus Offer World Class Virtual Instructor led training on Typo3. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email :
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –

Thank you for sharing excellent information. Your website is very cool. Fully useful your blog post... Online Shopping Website In Gujarat

The information which you have provided is really nice and awesome. magento development company uk Provides some very useful insights of how things actually work. I want to share something more about this as well.

Back To Top