How To Display Best Selling Products On Magento Store Home Page

Showing best selling products on your store’s home page is a great option especially if you are looking to promote best selling products even more. If you are looking to display best selling products on your home page you can do that by following simple ways:

  1. Show best selling products by creating best selling “attribute” and assign that attribute to the desired product.
  2. Query your database and find out actual data and then show best selling products based on your query.
  3. Create a category called “Bestselling” and assign your desired products to this particular category.

In this article i will explain how to show best selling products based on a category called “bestselling”.

Typically best selling product grid is either displayed on your store’s home page or sidebar. In our example we will try to display best selling product grid on home page.

Create “Bestselling” Category

Let’s create a new category “Bestselling” from admin. Go to Admin => Catalog => Categories => Manage Categories

Now, let’s set this category to “Is Active: No” just so that it does not show up in our category list in top navigation and other areas where you might be displaying list of all categories. At the top of the page you will notice “category id” which is our desired category id to fetch bestselling products and display on home page. In my example we will work with “Bestselling (id:179)”

Let’s assign few products under this “Bestselling” category which should be displayed on your store’s home page.

Code to Show Best Selling Products on Home Page

As we have Bestselling category created and some sample products assigned to this particular category we are ready to create a new code which will fetch all the products from category id 179 and display on our home page.

Open your ftp editor and go to app => design => frontend => base => default => template => catalog => product and create new php file called “bestsellers.phtml”. (considering that you are using default theme {change theme name and path according to your current selected theme})

Put the following code in bestsellers.phtml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
if ($_productCollection->count()):
$_iterator = 0;
 
foreach ($_productCollection as $_product): ?>
 
<div> <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(145); ?>" width="120" height="120" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<p><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></p>
<p><span><?php echo $this->getPriceHtml($_product, true) ?></span></p>
<p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><img src="images/more-info.gif" width="110" height="30" alt="More Info" /></a></p>
</div>
 
<?php endforeach; // end products loop ?>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php endif; // if product collection ?>

The above code will fetch product name, price and thumbnail from the system and display at a desired location. You should change the XHTML/CSS depending upon your themes requirements.

Finally we will call this piece of code on our store’s home page. Go to Admin => CMS => Pages and edit your store’s selected home page.

1
2
3
<div id="bestselling-grid">Best Selling Products</div>
 
{{block type="catalog/product_list" category_id="179" template="catalog/product/bestsellers.phtml"}}

In the above code just change the category_id value you have noted while creating new “Bestselling” category.

We are done. You can further customize this product grid by showing “Add to Cart” button, displaying as list or grid etc.

I would love to hear your experiences of showing best selling products on your store’s home page. Please leave me a comment and let me know. Subscribe our RSS to receive latest Magento updates, tips and tricks.

  • Pingback: How To Customize Magento Templates | MagentoMagik

  • Cheerio

    Very nice tutorial! Is there a way that the amount of products shown in the page is not limited to “Products per Page on Grid Default Value” that you can set in System -> Configuration -> Catalog ->Frontend. If that is set to 6 but I want to show 12 bestselling products how could I achieve that?

  • http://www.stylishandtrendy.com/ Dev @ Women Magazine

    Just play with $_productCollection->count() and it should work.

  • Wm

    Hey its a great extension, but can I get some help to display in rows, rather in column! Thanks in advance.

  • http://www.developer.web.tr Oğuz Çelikdemir

    There is a typo problem which is should be catalog/product/bestseller.phtml instead of catalog/product/best.phtml in the last part of code.

  • http://www.magentomagik.com/ Ashish @Magento Themes

    Ohh Yes, thank you for notifying, i am going to make the correction immediately. Thanks.

  • http://florencerogers.co.cc/ Florence Rogers

    Very nice tutorial! Is there a way that the amount of products shown in the page is not limited to “Products per Page on Grid Default Value” that you can set in System -> Configuration -> Catalog ->Frontend. If that is set to 6 but I want to show 12 bestselling products how could I achieve that?

  • http://ednanicholson.co.cc/ Edna Nicholson

    There is a typo problem which is should be catalog/product/bestseller.phtml instead of catalog/product/best.phtml in the last part of code.

  • http://www.gigbowl.com buy stuff online

    The article was definitely a good read & I respect not crappy content on the net since alot is dupicate. I recognize that in the area of site content it’s for all purposes King for the matter of getting a site ranked and so on (undoubtely the reason I saw this). I’ve worked with a couple webpages back when and am putting time on an internet micro gigs marketplace type site made for members to go on and buy and sell services to one another. That being said I have to spend some time on writing some blog content and what not on the site and what not. So anyway take care and keep getting out good content.

  • Kankakankatika K

    I am using magento 1.5 version,I followed ur steps but not displaying best sellers products.Plz help

  • http://www.google.com Helen A. Lassiter

    Aw, this was a very nice post. In thought I wish to put in writing like this additionally – taking time and actual effort to make a very good article… however what can I say… I procrastinate alot and by no means appear to get one thing done.

  • Daniel

    How do I change the order on the list?

  • Peter

    This is more like a featured product list rather than a dynamic best seller functionality, isn’t it? With this method someone constantly needs to analyze the data and change the list manually, instead of letting Magento monitor and update the top 10-15 products that sell in the biggest numbers.

  • http://tester.com Adaware Removal

    Thanks on your marvelous posting! I genuinely enjoyed reading it, you are a great author.I will be sure to bookmark your blog and will come back in the future. I want to encourage you to ultimately continue your great posts, have a nice morning!

  • Rudra Prakash

    my code is displying only

  • Mukesh saini

    very good code,
     use and happy

  • rohit goel

    hi this id very good code

  • Abdulrehman82

    how to display this code in left column

  • http://psdtomagento.net psd to magento

    Very nice idea, thanks man!

  • Sankhabanerjee92

    This is the best code….Thanks for help.Caty on..

  • Vivek Shingala

    hey its not working.

    please tell me, where to place the code in cms page?

  • Mayur Panchal

    i m not able to see all the product 

  • Anonymous

    Hello,

    You need to place the code in cms page content area.

  • Андрей Сирик

    hi this is my code, but not working, because class mainA out of loop , pleas helpб what code is correct

               
                getLoadedProductCollection();
                    $_helper = $this->helper(‘catalog/output’);
                    if ($_productCollection->count()):
                    $_iterator = 0;
                     
                    ?>
               
             
                            getUrl();
                                  $name = $category->getName();
                                } elseif ( $categories = $_product->getCategoryIds()) {
                                  $category = Mage::getModel(‘catalog/category’)->load($categories[2]);
                                  $url = $category->getUrl();
                                  $name = $category->getName();
                                }
                                $link = is_null($url);
                            ?>
      
            <a href="getProductUrl() ?>” title=”stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>” class=”product-image”><img class="imgA" src="helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(135); ?>” width=”95″ height=”95″ alt=”stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>” />
      
         
               
                   
                        <a href="getProductUrl() ?>” title=”stripTags($_product->getName(), null, true) ?>”>productAttribute($_product, $_product->getName(), ‘name’) ?>
                   
                    See all: <a href="”>  

               
           
      
      
         

  • http://www.fmeextensions.com/ Magento Modules

    same happens for me! did you resolve it

  • vishambar

    i have add N number of products with this category but only one product display

  • http://popinjayblog.com

    Oh, duh! Very helpful, thanks. http://popinjayblog.com

  • Дмитрий Маринов

    Great! It Works

  • http://magento.com Kiên Bờm

    great post