Tuesday , December 12 2017
Home >> All tutorial >> How To Display Best Selling Products On Magento Store Home Page

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. <?php
  2. $_productCollection=$this->getLoadedProductCollection();
  3. $_helper = $this->helper(‘catalog/output’);
  4. if ($_productCollection->count()):
  5. $_iterator = 0;
  6.  
  7. foreach ($_productCollection as $_product): ?>
  8.  
  9. <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>
  10. <p><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></p>
  11. <p><span><?php echo $this->getPriceHtml($_product, true) ?></span></p>
  12. <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>
  13. </div>
  14.  
  15. <?php endforeach; // end products loop ?>
  16. <script type=“text/javascript”>decorateList(‘products-list’, ‘none-recursive’)</script>
  17. <?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. <div id=“bestselling-grid”>Best Selling Products</div>
  2.  
  3. {{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.

We also contribute great content of Magento Download for FREE (all versions)

DON'T MISS THE CHANCE!

magento download

About Champ

4 comments

  1. Hi

    How To Display new Products On Magento Store Home Page?

    thanks

  2. Hi Alice

    How to setup extension downloaded from github.com.(Install without magento connect)

    thanks your articles perfect.

    • Hi,

      You can reach github.com. They instructed about extension installation carefully.
      Hope it helpful for you!

      Best Regards,
      Alice

Leave a Reply

Your email address will not be published. Required fields are marked *

Heap | Mobile and Web Analytics