Home » Magento30 January 2011

Magento: How to get top rated products?

Here, I will be showing you how to get the top/highest rated product.

The basic idea for getting the top rated products is fetching all products, looping through them, getting ratings of each product and populating a ratings array. After that sort the array and then slice the array for limiting the number of product to display.

Here is the function to get the top rated products:-

Now, you can display the products in any template file. Here is the sample code to display the top rated products:-

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Tung Phamthanh90

    Actual, this way return array product, not is product collection type

  • Syntax3rror

    Yow.. I think Its too deep if you will convert to a colletion objetc. :)

  • Konrad

    I think that The better way to get products is to get them direct from rating_option_vote_aggregated  table and sort it by rating, then add to array of top rated products just enabled ones.
    Becouse if you take all products it may limit your server memory. I had this issue when tried to find top 10 best rated products from 7000+ all products.

    You can then add some variations to your query, for example if you want to take top 10 products and you have 500+ rows in database you can assume that you’ll need at the most a half of it, so you can limit your query -> limit number of loop goes.


  • You can get top rated products by adding a Sort by rating option in Magento Sort by drop down menu. Sort by rating is not included in default Sorting options. Once you add sort by rating option, you can sort the products in descending order which will display the top rated products on top of the list.