Display special priced products on your Magento homepage

In my previous blogpost, I covered how you can create a €1 Bargain page in Magento. To do so, we learned how to create a custom block on wich we applied price as a filter on the product collection and how to create a XML Layout update for a random CMS page. The main advantage of this method for creating custom catalog pages in Magento is that the toolbar, pagination, navigation layered, caches & indexes all continue to function correctly. In this post, I want to show you how you can use this same method to display all products with a special price on the frontpage of your Magento webshop

Step one
Open your homepage CMS page and click on the design tab. Paste the following:

Because my frontpage has 3 columns, you can see I have set the amount of columns in the grid view to 3 using the action method "addColumnCountLayoutDepend".  I have set 2 as the categoryId, because this the id of my root category. Be sure that you use the correct id of the category you want to display and be sure that it's set to be an Anchor (or it won't display any products in the first place).

Step two
In the XML update above, you can see we call catalog/product_specials as the block type. What we are going to do now, is creating a custom block where we actually apply our custom pricefilters. To do so, make a copy of /app/code/core/Mage/Catalog/Block/Product/List.php, create the directory /app/code/local/Mage/Catalog/Block/Product and place it there. Rename this file to Specials.php

Step three
Edit Specials.php and change the class definition (the first line of actual code, line number 35):


Scroll to around line 89, and you'll find the following definition

After this definition, we can do some magic. Place the following code just below it:

As you can see, we just define today's date and tomorrow's date and then apply the special_from_date and special_to_date as attribute's to filter. Because we can imagine you will not always set a 'to' date when giving your products a special price, we use Zend_DB_Expr to say it should also add products to the product collection that don't have a 'to' date configured. If you do wan't to display only the products that have a value for both the from and to date, use this code instead:

How to limit the amount of products to display

Imagine you want to display not ALL products in a certain category, but want to limit the amount to let's say 5 (randoms if you want). For example: you want to create a featured products block in Magento. To do so, you can use this exact same method (copy the List.php, name it Featured.php' etc. etc) and you will only have to make some small changes to your XML:

Now, pay attention to what I'm doing here, because this example won't just work when you copy paste it. First, you'll see that I indeed call my custom block catalog/product_featured and use a custom template to display the results: catalog/product/featured.phtml. You can use list.phtml here if you want to do a quick test. Now on line 4, you'll see that I give the toolbar a custom name: product_featured_toolbar and that I use an action method on the next line to set the addPageLimit for listview to limit the results to 5 products. If you want to use a custom gridview, you can change the mode to grid. Last but not least, on line 7 I use the action method setToolbarBlockName to identify the custom toolbar so that my addPagerLimit will only affect the toolbar from this specific block. If you don't use a custom name for your toolbar, you'll see that all other listviews on the page will be affected and in most cases you probably do not want that.

H&O is expert in het oplossen van complexe Magento vraagstukken, maatwerk grafisch ontwerp en het bouwen van custom Magento modules.

Als je op zoek bent naar een partner die je kan helpen met het beantwoorden van moeilijke Magento vragen, een maatwerk productimport voor je ontwikkeld of een custom Magento module voor je schrijft die jouw assortiment met een andere webshop koppelt, dan ben je aan het juiste adres. H&O heeft zich sinds 2007 verdiept in de techniek en ontwikkelingen van het e-commerce CMS, speelt een actieve rol in de community, heeft verschillende modules uitgebracht en heeft voor klanten uiteenlopende technische modules ontwikkeld. Ons kantoor is gevestigd in Roelofarendsveen, direct naast de A4 én slechts op 15 minuten afstand van Amsterdam. Neem contact met ons op en kom eens langs, dan bespreken we jouw vraagstuk!

Erwin Otten

Erwin Otten is a Web Designer / Graphic Designer from Oude Wetering (The Netherlands) and co-founder of Hachmang & Otten. With an education in communication & multimedia design, he is passionate about web design at all levels including (information) architecture, interaction, code, and graphic design. Contact Erwin Otten

  • Derek Johnson

    (nov 17)
    Reply to this comment

    Works well, thank you. I needed to correct a typo in the XML. It should say type=“catalog/product_specials” not type=“catalog/product_bargains”

  • Admin

    (nov 20)
    Reply to this comment

    Thanks, fixed it!

  • Kay Beissert

    (dec 15)
    Reply to this comment

    Thank you verry much. This works perfect. Is possible to disply the filter-block on the left side to filter the displayed products?


  • ktsixit

    (mar 02)
    Reply to this comment

    I did exactly what you suggested but no products appear.
    I did’t add the last part (“How to limit the amount of products to display”) but I guess that it would be enough.

    • Erwin Otten

      (mar 03)
      Reply to this comment

      That is correct, you don’t have to add the addPagerLimit in to see products showing up. Have you used the correct categoryId of your parent category? Have you actually gave some products a special date?

      • Conor

        (mei 06)
        Reply to this comment

        I have the same problem and I can not get them to show on the home page at all, please help. I am running

  • Katapofatico

    (mei 25)
    Reply to this comment

    Thaks for your contribution, Erwin. And… what about catalog rules special priced products? Have you any idea on how to list them, or even include them in this module?
    Thanks again!

  • izdelava spletnih strani

    (jun 28)
    Reply to this comment

    TNX for this great article!

  • Tjerco

    (jul 29)
    Reply to this comment

    Hi Guys,

    This working fine for me (release 1.5). I do have a small question? In which statement of the new specials.php is the number of products given back? I have a dubble statement on the frontend now.


    • Paul Hachmang

      (jul 30)
      Reply to this comment

      Could you please provide a screenshot?

    • Paul Hachmang

      (aug 01)
      Reply to this comment

      I received the following screenshot: http://cl.ly/8wpL

      You could try and remove from the XML

      < block type=“catalog/product_list_toolbar” name=“product_list_toolbar” template=“catalog/product/list/toolbar.phtml” >
        < block type=“page/html_pager” name=“product_list_toolbar_pager” >       
      </ block >

      If that doesn’t work, look in your list.phtml template.

  • Francesco

    (nov 17)
    Reply to this comment

    this is a great tutorial, thanks! I have used it to create a static “Promotions” page.
    For the home page, I would rather like to diplay the two last products with a special price using a custom block.
    But it is not clear to me where the XML code must be inserted…can you please explain me the last part of your tutorial?

    Thanks a lot in advance,

  • amadex

    (dec 31)
    Reply to this comment

    Very, very good tutorial!!!! One doubt still: layered navigation keeps “considering” all the products of the category and not only the “bargain” ones. Any help?

    • Alberto

      (sep 03)
      Reply to this comment

      Amadex, then you could do also filering by category, byt this code:


  • Marko

    (mei 06)
    Reply to this comment

    Thanks. This code is working perfect!

  • Alberto

    (sep 03)
    Reply to this comment

    Thank you very much! you helped me to implement some custom product listing ;)

  • Phil

    (sep 04)
    Reply to this comment

    Thanks, the code works well, great tutorial!

  • David

    (nov 05)
    Reply to this comment

    Hey, this worked great.  Thanks for that.  The code shows 2 products with special prices when I got it all done. However, I have 10 products that I’ve marked with special prices, all with the same date range.  Any idea how I can debug to figure out why only 2 of the 10 are showing up?

  • brijin

    (nov 27)
    Reply to this comment

    to set limit add ,
    <action method=“addPagerLimit”><mode>list</mode><limit>5</limit></action> to CMS/design page guyz…..

  • Filip

    (mar 16)
    Reply to this comment

    Worked great! Thank you very much!

    (probably common) mistake that bugged me:
    - enter the default category id in the xml update code (it’s in Manage Categories -> you have to click on the wanted category and the id’s by the category name)

  • Christian Ellsworth

    (jul 17)
    Reply to this comment

    This solution works but the products always drop a day early. For example with this solution if I scheduled a product to end the special price today it will not show but will still be on sale until the end of the day.

  • Andrew

    (dec 09)
    Reply to this comment

    Hi, I’m pretty new with Magento. I’m trying to figure out this first instruction: “Open your homepage CMS page and click on the design tab”.  Couldn’t find it anywhere.  I tried going to CMS > Pages but couldn’t see a homepage page. Should I create a new page then? Thanks!

  • Alberto

    (feb 19)
    Reply to this comment

    Excellent solution, works great. How do I include in the filter discounted products with the rules of the catalog?



Bel mij terug

Vul uw telefoonnummer in en we bellen u zo spoedig mogelijk terug.


Veenderveld 20
2371 TV
071 744 0084
KvK Rijnland nr. 28119089
BTW nr. NL818554071B01

Nieuwe projecten

Wilt u weten wat H&O kan betekenen voor uw Magento project? Stuur ons een mailtje:

Paul Hachmang


Erwin Otten