• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Elias Interactive

We Grow Beautiful Websites

  • Blog
  • Show Search
Hide Search

Magento Featured Products: A More Convenient Way To Display Featured Products On The Home Page

Lee Taylor · May 25, 2009 · 54 Comments

About: How To Show / Display Featured Products On The Home Page (Conveniently)

Who’s Interested: Informative to the technical gurus
What: An alternative direction on how to show featured products on your Magento storefront home page
Magento Version Relevance: Any
Magento Store Setup: Any

My thought: “Why not let the Admin choose what products to display on the home page like every other category?”

If you’ve been involved in the community dialogue that constantly evolves through the Magento boards, you may have run across a topic mainly focused on ways for developers to display featured products on the home page.

There have been many directions taken with this, including the following as only a few to mention:

  1. Install a extension and configure
  2. Create an attribute, assign each product a value for that attribute, and then display products based upon the value they contain for that attribute
  3. Use the CMS template code to display a certain category

I didn’t want to override any other solutions, but simply offer another approach – one that does not do the following:

  • Modify any core code
  • Require per-product management
  • Install any extension

After my review, I still wanted a way that was more convenient for our client/administrators to be able to manage the products that display on their home page. Going through each product can become cumbersome, so what if they had one specific category that gets displayed all the time, and any products within it show up on the home page? That’s what I went for, and came up with the following:

  1. Create a new “structural block” within Magento (see example, thanks Inchoo)
  2. Create a (hidden) category within the Magento Admin
  3. Modify the structural block to display that category in a specific way
  4. Set the Category Id

Here are the files/modifications:

Structural Block

  • app/design/frontend/*/*/template/catalog/product/featured-products.phtml
/*
Magento

NOTICE OF LICENSE

This source file is subject to the Academic Free License (AFL 3.0) that is bundled with this package in the file LICENSE_AFL.txt. It is also available through the world-wide-web at this URL:
http://opensource.org/licenses/afl-3.0.php
If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@magentocommerce.com so we can send you a copy immediately.

DISCLAIMER

Do not edit or add to this file if you wish to upgrade Magento to newer versions in the future. If you wish to customize Magento for your needs please refer to http://www.magentocommerce.com for more information.

@category   design_default
@package    Mage
@copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
@license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

<?php
/*
Product list template

@see Mage_Catalog_Block_Product_List
*/
?>

<?php //$_productCollection=$this->getLoadedProductCollection()

//var_dump($cModel); echo $cModel->getName(); die;

$cat_id = "7"; // category_id for "Featured Products"
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image'), 'inner')
->addCategoryFilter(Mage::getModel('catalog/category')->load($cat_id));

?>

<?php if(!$_productCollection->count()): ?>
<div class="padder">
<div class="note-msg">
<?php echo $this->__('There are no products matching the selection.') ?>
</div>
</div>
<?php else: ?>

<? // Removed List Mode ?>

<?php // Grid Mode ?>
<?php $_iterator = 0; ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php //var_dump($_productCollection->count()); ?>
<div class="listing-type-list catalog-listing padder">
<table cellspacing="0" class="generic-product-grid" id="product-list-table">
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%2==0): ?>
<tr>
<?php endif ?>
<td>
<p class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(95, 95); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>
<h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h5>
<?php //echo $this->getPriceHtml($_product, true) ?>

</p>
</td>
<?php if ($i%2==0 	&#37; $i!=$_collectionSize): ?>
</tr>
<?php endif ?>
<?php endforeach ?>
<?php for($i;$i%2!=0;$i++): ?>
<td class="empty-product">	&#37;</td>
<?php endfor ?>
<?php if ($i%2==0): ?>
</tr>
<?php endif ?>
</table>
<script type="text/javascript">decorateTable('product-list-table')</script>
</div>

<?php endif; ?>
  • app/design/frontend/*/*/template/cms/home.phtml (modify path/to/your/cms/page/home.phtml to be specific to your needs)
<?php //Home Page View ?> <div>
<?php //display featured products ?>
<?php echo $this->getChildHtml('featured.products') ?>
</div>
  • app/design/frontend/*/*/layout/page/page.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<!-- Default layout, loads most of the pages -->
<!-- Insert into existing page.xml file, do not replace this with your current file -->
<default>
<block type="core/text_list" name="featured.products" as="featured.products"/>
</default>
</layout>

Create new Category

This ccould be called “Featured Products”) and set the Admin->Catalog->Manage Categories->specificCategoryName->General Information->”Is Active” = “No”.

Display structural block

Either via CMS page or .phtml page through the CMS page:
(modify path/to/your/cms/page/home.phtml to be specific to your needs)

  • CMS Page: {{block type=”core/template” template=”path/to/your/cms/page/home.phtml”}}
  • .phtml page: inside CMS page->Custom Design:
<reference name="content">
<remove name="cms_page" />
<block name="home_page" type="core/template" template="path/to/your/cms/page/home.phtml">
<block name="featured.products" type="catalog/product_list" template=
"catalog/product/featured-products.phtml" />
</block>
</reference>
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>

Set Your Category Id

Now you should be able to checkout the code in the featured-products.phtml, and match the “7” to your actual product category id. (see category id within the Admin->Catalog->Manage Categories->Your Category).


Now, any product inside that category gets displayed on the home page!

Please feel free to download the structural block files and place into your theme structure relative to the root Magento directory.

And take a look at the site we’ve used it on with our client, Keramikos Kitchen.

Let us know your thoughts!

Appreciative,
Lee

Share this:

  • Tweet
  • Pocket
  • More
  • Email

Blog, Development featured products, featured products on home page, Magento, Magento Commerce, magento development

Reader Interactions

Comments

  1. solmyr says

    May 27, 2009 at 5:51 am

    Great approach! Much cheaper than Featured Product for 89$
    Thank you for the sharing.

    Reply
  2. Bivek says

    May 28, 2009 at 9:55 pm

    Hi i want to reverse the order of showing the product.

    How can i do it?

    Reply
  3. Firestorm says

    June 9, 2009 at 7:10 pm

    Hey, nice implementation. I did something similar to show children categories for a quick links section on a site. I’m working on extending the core to make it a bit more elegant… but that’s a lot more work. This is really nice, though. Good stuff, guys!

    Reply
  4. Milos says

    June 22, 2009 at 8:36 am

    I tried to follow your instructions but everything I did didn’t work with latest magento install. Did anyone managed to get this peace of code working?

    Thanks!

    Reply
  5. combicart says

    June 24, 2009 at 10:28 am

    I also can’t get it to work. The idea however is great!
    Could you perhaps explain in more detail ‘(modify path/to/your/cms/page/home.phtml to be specific to your needs)’ and give some extra information on step 3?

    Reply
  6. Kristof says

    July 8, 2009 at 10:22 am

    Why would you bother to change the code anyway?

    Just create a subcategory thats called ‘featured products’ put this category on non active.
    Add products to it in the tab ‘category products’, choose any product from any existing category you want.

    Then go to the cms an choose the homepage.
    Put this there:

    {{block type=”catalog/product_list” category_id=”43″ template=”catalog/product/list.phtml”}}

    (where 43 is the id of your new category)

    Et voila… you have your own featured products page

    Reply
  7. Lee Taylor says

    July 8, 2009 at 10:46 am

    Hi @Kristof,

    Thanks for the input! And you are very correct, one would be able to use that template code in order to display a specific category’s product listing. Though what if one would desire to manipulate any part of the page with PHP? PHP is not allowed via the Magento CMS, so one is restricted in this regard. It’s not a solution for all to use if all that is desired doesn’t require any customization. With utilizing this method we provided, however, there is full flexibility and anything is possible.

    Cheers for your discussion,
    Lee

    Reply
  8. Lee Taylor says

    July 8, 2009 at 10:49 am

    Hi @combicart,

    Regarding the question you had, “/path/to/home.phtml” is something you need to change to match your home.phtml file wherever you placed it within your template file.

    Also, step 3 places that XML code inside of the “Custom Design” section of your Magento CMS within the Admin. It will be the code that tells your system to use/display the home.phtml page instead of what shows inside of the CMS Admin page.

    Does this help?

    Cheers,
    Lee

    Reply
  9. Mike says

    July 8, 2009 at 7:05 pm

    Not working, think I followed all the steps. Still a little more help on step 3 would be great!

    Reply
  10. Fernando says

    July 12, 2009 at 7:35 am

    Hey, i’ve been trying to get a couple different featured products modules working but to no avail.

    It currently says There are no products matching the selection.

    http://www.cubaseabrio.com Any ideas by chance? D: I’ve retried it a couple of times now. The first time I didn’t get the 1. 2. 3. 4. and this time i did. O.o

    Reply
  11. Akki says

    July 22, 2009 at 2:50 am

    Hey ,

    you have given very good implementation. will u help me out from my below problem .

    i’ve been trying to get a couple of different POPULAR CATEGORIES into my home page. I am using 3 coloums layout.
    problem is that how m i display category on mid part of the page along with image and their product . if any procedure or code if u have ?then plz share with me.

    Thank you

    Reply
  12. John says

    July 22, 2009 at 2:17 pm

    Fernando, you have/had the same problem as me. I fixed it by moving the featured category inside the root category instead of next to it. This screwed up other things, but it should lead you in the right direction.

    Reply
  13. Akki says

    July 22, 2009 at 11:52 pm

    Hi,

    can any one help me ?? how to display advertisement into home page

    Reply
  14. Akki says

    July 22, 2009 at 11:57 pm

    hi Fernando,

    thanks for reply ,

    your post is not helpful its really screwed for other things.
    so send me another direction which i use n lead to in right direction

    Reply
  15. DougHold says

    July 30, 2009 at 10:02 am

    This was a great post, not only did it help me achieve what I was trying to do, but I was able to learn how the theming system in Magento works! Thanks!

    Reply
  16. Sameep says

    August 6, 2009 at 12:39 am

    @Akki : Try Lazzymonks Google Ads extension. It is available in Magento Extensions.

    http://www.magentocommerce.com/extension/308/lazzymonks-google-ads

    Reply
  17. DougHold says

    August 7, 2009 at 11:27 am

    I leveraged this to loop through subcategories of the “Featured Product” category and populate the products in each category into their own jQuery Coda Slider panel (one of those sliders with arrows and links that you can elegantly slide through all of the containers). If anyone is interested PM me at doughold on the Magento site. Thanks again for this post!

    Reply
  18. Lee Taylor says

    August 7, 2009 at 11:31 am

    Thanks for the note @DougHold! Would you mind sharing a link so we can enjoy the results?

    Also, feel free to pass along any instruction you think the community could benefit from 🙂

    Cheers,
    Lee

    Reply
  19. DougHold says

    August 7, 2009 at 2:53 pm

    @Lee I am under a tight deadline but would be more than happy to post some instructions when I complete the project (next week sometime). For now you can visit http://tt.westechsolutions.com to see what I’ve done or the final site will be http://www.tastefultreats.com.

    Reply
  20. Lee Taylor says

    August 7, 2009 at 3:57 pm

    Great work @DougHold!

    Thanks for sharing.

    All the best on the current project you have going.

    —
    Lee

    Reply
  21. Etienne says

    August 13, 2009 at 8:43 pm

    wasted my time – doesn’t work with classic theme – completed the steps twice – 2 hours wasted – have to move on. *** GRR

    Reply
  22. Wayne says

    August 18, 2009 at 3:29 pm

    Thank you, this works really well indeed for me – have struggled to find something which works quite as well as this without adding new files to core related folders or creating new modules. Very, very nice work.

    As for those who compain about time getting wasted etc – he didn’t need to post this tutorial, but he did! Even if it works for only 1 person it’s worth doing, however it’s worked for many. You take the risk by trying it out yourself, if it doesn’t work for you, tuff, try something else!

    Reply
  23. Lee Taylor says

    August 20, 2009 at 6:13 pm

    Thanks @Wayne,

    Great perspective here, and I’m glad you found this helpful.

    All the best on your endeavors!
    Lee

    Reply
  24. DougHold says

    September 7, 2009 at 2:18 pm

    @Lee I have posted what I did to get the coda slider working in the Magento forums http://www.magentocommerce.com/boards/viewthread/54331/

    Reply
  25. Mike says

    September 9, 2009 at 1:24 am

    Thanks for sharing your work.

    Is there a way to get the price to show? I saw that the line was commented out. I removed the comment slashes, but the price does not appear. Any ideas?

    Reply
  26. Lee Taylor says

    September 9, 2009 at 11:49 am

    @DougHold, thanks for the community involvement! We’re glad you’re on board.

    —
    Lee

    Reply
  27. Lee Taylor says

    September 9, 2009 at 11:51 am

    @Mike,

    Try dumping out the $_product array some time after line 68 or so. Once within the loop, you should see the other variables/values such as “price” since we included it in the attributes to be selected near line 40-42.

    Thanks!
    Lee

    Reply
  28. Ian Yates says

    September 11, 2009 at 9:54 am

    Hi Lee,

    Fantastic stuff, worked a treat.

    For my site I’d like to just output 3 products, randomly chosen from the Featured Products category. Is this easily achieved?

    Appreciate your sharing.

    Reply
  29. Jeremy says

    September 11, 2009 at 12:55 pm

    Is there a way that you can add an “Add to cart” button on the featured section? I am using this code to display the items in the list.phtml file:

    <a href=”#” onclick=”setLocation(‘getAddToCartUrl($_product) ?>’)”><img src=”getSkinUrl(‘images/buttons/btn-add-to-cart.gif’) ?>” alt=”__(‘Add to Cart’) ?>” title=”__(‘Add to Cart’) ?>” />

    Thanks

    Reply
  30. dinesh says

    September 16, 2009 at 9:31 am

    Thanks. at last i got proper solutions to disply featured product

    Reply
  31. Toyman says

    October 22, 2009 at 3:41 pm

    Hi – so I followed this to a “T” and I have a few questions. This seems to load on the page although nothing displays – the is in the code but the reference between the tag is empty.

    when you mention “home.phtml” I’m not sure which file you’re referring to. I am running ver. 1.3.2.3 and within /cms/ I don’t have a “page” directory. There is a “default” directory and within that is “home.phtml” however when I open this in dreamweaver I see “There was no Home CMS page configured or found.”.

    I added in the tag, though to “1column.phtml” found in /page/ directory with no real results.

    Thanks!

    Reply
  32. Ionifeinfonna says

    December 11, 2009 at 3:52 pm

    I’m always searching for brand-new informations in the net about this theme. Thx!!

    Reply
  33. Tomislav Bilic says

    December 21, 2009 at 10:51 am

    Hello guys,

    You might be interested in taking a look at Featured Products by Inchoo, free Magento community extension.
    http://inchoo.net/ecommerce/magento/featured-products-on-magento-frontpage/

    Hope this helps someone.

    Cheers!

    Reply
  34. steward says

    February 11, 2010 at 10:32 am

    Great thank you.

    For those who cannot make it work, here is something else to check: I cut and pates from this page, but the character set got mangled in the process, eg quotes to curly quotes and one character changed to a question mark.

    After correcting that, poof she worked great.

    Reply
  35. Lee Taylor says

    February 11, 2010 at 2:14 pm

    Thanks @steward,

    This is very true. Be sure to check the “copy & paste” characters if you do it that way. Otherwise, use the “copy” feature as you hover over the code.

    Glad it helped!
    Lee

    Reply
  36. Raularam says

    February 28, 2010 at 11:28 pm

    Wow! This actually works like a charm. It works, even on version 1.4.0.1. Thank you Lee. you save me a lot of work to get this done!!

    Reply
  37. Lee Taylor says

    March 1, 2010 at 4:06 pm

    Great to know it worked for your @Raularam! Thanks for sharing.

    Reply
  38. Amit says

    March 4, 2010 at 8:13 am

    “
    08.
    09.
    10.”
    where to insert those lines in page.xml

    Reply
  39. Amit says

    March 4, 2010 at 8:14 am

    where to insert those lines in page.xml

    Reply
  40. Kyle says

    March 11, 2010 at 11:51 am

    Hi Lee, thanks so much for this post – I’ve been trying for a long time to get something like this to work, and your code is the only thing that has so far.

    I ‘m not a programmer, though, so I’m a little confused when I see this:

    getPriceHtml($_product, true) ?>

    getShortDescription()) ?>
    <a href="getProductUrl() ?>” title=”htmlEscape($_product->getName()) ?>”>__(‘Learn More’) ?>

    but I don’t see the price or short description in the browser – just the “Learn more” link. Any ideas?

    Thanks.

    Reply
  41. Lee Taylor says

    March 12, 2010 at 4:01 pm

    Hey @Kyle,

    It might take you some time to figure out if you’re not a programmer. What you could do is make sure the data is being drawn into the right view, so throw this code under the “Learn more” code:

    getData()); ?> 

    If the data is there, then it should be displaying. Otherwise, it could be related to stock levels, product configuration, theme issues. Might be better to hire a developer at that point.

    Cheers,
    Lee

    Reply
  42. Kyle says

    March 12, 2010 at 8:11 pm

    Thanks for the response, Lee. I did as you suggested, and the data is visible. I can pick out the price, but I don’t see any data for short description

    I’m guessing theme issues, or I may have missed a step. I’ll run through your directions again.

    Thanks again!

    Kyle

    Reply
  43. Duntuk says

    March 25, 2010 at 6:05 pm

    Just want to give a heads up of how i got this to work:

    1. create the “featured products” directory, and get the cat id# for that.

    2. use the file “featured-products.phtml” from the posted link, and put in cat id#:
    http://67.225.241.61/ei/wp-content/uploads/2009/05/elias-featured-products-tutorial-files.zip
    Do not copy/paste, or “view source” or any feature associated by hovering over the code, it’s different from the zip.

    3. skip all the other steps, and put this into your CMS Content section:

    {{block type=”catalog/product_list” template=”catalog/product/featured-products.phtml”}}

    Reply
  44. Jaime says

    May 16, 2010 at 7:08 pm

    Hello…

    This worked great, but I have one question. I want to place a title for the grid of featured products.

    I added in featured-products.phml this line:
    __(‘Featured Products’); ?>

    Now, I want to localize “Feature Products” text. Where is the best CSV file to place it? I don’t want to modify CSV’s that come with Magento. I created a file called featured_products.csv and placed it under locale folder, but it did not work.

    Any help will be appreciated
    Thanks

    Jaime

    Reply
  45. peter says

    June 30, 2010 at 5:46 pm

    really great post and worked like charm for me …cheers for that

    Reply
  46. mohit says

    July 10, 2010 at 9:06 am

    thanks for this code…..because i have used many code but i am tired………
    but after use this code every think fine………….

    Reply
  47. Brando Bandit says

    August 27, 2010 at 5:49 am

    Hi Lee! Thanks for this! But how can I show the products in a random manner?

    Reply
  48. Brando Bandit says

    August 27, 2010 at 5:53 am

    Also How can I show only one product? So everytime I refresh the browser, the products will display randomized.

    Reply
  49. Brando Bandit says

    August 27, 2010 at 6:34 am

    Oh, no worries! I solved it already… thanks!

    Reply
  50. Raise says

    June 25, 2011 at 5:43 am

    Hello There

    We have been searching for the proper solutions to find the title and url of cms pages of magento.

    We tried to find the title and url of cms pages of magento.

    At last we find the solution, and we would like to share it with you all.

    We have a url which can help you.

    Click here: http://www.raiseitsolutions.com/forum/viewtopic.php?f=24&t=24&sid=0c299a2224ad5dbca43b4c27b36acaac

    We hope that is enough for you.

    All The Best
     

    Reply
  51. Muyu945 says

    July 8, 2011 at 1:15 am

    hello, i have done all as you said, but why the featured products just display only one ? anyone else meet the same problem?

    Reply
  52. Yasraj says

    June 4, 2012 at 10:26 am

    it is not working for me

    Reply
  53. Lindsey says

    November 3, 2015 at 9:00 pm

    Hi I am running a standard magento install. I am now wondering is it possible to instruct magento to display prices for some products but not for others? I thought the above logic might work but then it occurred to me that there may also be a plugin that enables this already. I’d appreciate any input.

    Thanks

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

From the blog

Magento SVN Usage – Best Practices

How to Create Reusable Apple Mail Templates [video]

I’d rather buy from Harry Potter

The Ecommerce Solution You’ll Find Refreshing (drumroll)

Liberating Constraints

More Posts

Connect with us

  • Facebook
  • RSS
  • Twitter
Affiliate Disclaimer

© 2025 · Elias Interactive · Built on the Genesis Framework

  • Blog
  • Affiliate Disclaimer
  • Home