How to display bestselling products in Magento

We’ve noticed that many store owners ask questions about methods of displaying bestselling products on their Magento stores. Say, you need to show the most popular items on your Home page or Category View page.

Unfortunately, there’s no such default feature in Magento, but you can easily do this yourself. Read on to see the instructions!

Steps to display bestselling products on a page in Magento

1. Create a new file for Block:

Magento_root/app/code/local/Mage/Catalog/Block/Product/Bestseller.php

You can download the file for free at the end of the article. The file contains the algorithm of returning the necessary products collection, Bestsellers in our case.

2. Create a template file for the new block:

Magento_root/app/design/frontend/base/default/template/catalog/product/bestseller.phtml

You can download the file for free at the end of the article. This file works with visualization of our bestsellers collection on a given page. It is just an example; you are welcome to use the list.phtml template from your theme. Please do not forget to do that so the look of the collection is adjusted to your website’s design.

3. Now you need to call the created block, to do that go to Backend > CMS > Pages > Edit Page ‘Home page’ and add the following lines of code:

{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml" header="Bestsellers" limit=4}}

Also you can add a new block via layout update:

<reference name="content">
        <block type="catalog/product_bestseller" name="bestseller" template="catalog/product/bestseller.phtml" before="-">
            <action method="setLimit"><limit>3</limit></action>
            <action method="setHeader"><header>Best Sellers</header></action>
        </block>
</reference>

For instance, try to add this block to the Category View page here:

Backend > Catalog > Manage Categories > Click needed category in the category tree > `Custom Design` horizontal tab > ` Custom Layout Update` field

Feel free to manipulate the result using the header and the limit variables.

If just adding a list of bestsellers is not enough, consider checking the Improved Sorting extension, which is also compatible with layered navigation. It lets your customers sort the products by Best Selling, Most Viewed, Top Rated, Reviews Count, and other parameters.
Please note that this solution doesn’t work with Flat Catalog. To make this work, please disable this option in your store settings.

SUPEE-6788 update

When adding the block to the CMS page or Static block and using the following code:

{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml" header="Bestsellers" limit=4}}

you need to create a permission for this block:
Backend – > System – > Permissions – > Blocks – > `Add New Block` button
Bestseller SUPEE-6788 update
This manipulation is needed to be done for Magento 1.9.2.2 and higher or after installing SUPEE-6788 security patch.
Adding the block via Custom Layout Update works well in any situation:

<reference name="content">
<block type="catalog/product_bestseller" name="bestseller" template="catalog/product/bestseller.phtml" before="-">
<action method="setLimit"><limit>4</limit></action>
<action method="setHeader"><header>Best Sellers</header></action>
</block>
</reference>

26.01.2016 update

The code now works with flat catalog, plus the category variable is added, and you can use a certain category for the product selection.
Add Magento bestsellers via CMS block:

{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml" header="Bestsellers" limit=4 category=24}}

Add Magento bestsellers via layout update:

<reference name="content">
    <block type="catalog/product_bestseller" name="bestseller" template="catalog/product/bestseller.phtml" before="-">
        <action method="setLimit"><limit>4</limit></action>
        <action method="setHeader"><header>Best Sellers</header></action>
        <action method="setCategory"><category>24</category></action>
    </block>
</reference>

Download the Bestseller.php and the bestseller.phtml files with source code for free: