Richard Castera

Application Developer/Designer
  • Home
  • About
  • Projects

Magento – Display new products on the home page

If you’ve ever wanted to add new products in your Magento home page, it’s fairly easy to implement. Go to “CMS” then “Manage Pages” and select “Home Page” from the list of pages. Now paste this code snippet to show products labeled as “new” on your front page:

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

(Note that you must have some new products in your catalog for anything to show when you do this. This doesn’t mean that you’ve recently added them; only products explicitly marked as new using “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page in the admin tool will be shown.)

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Don't forget to Subscribe and Follow!

Be sure to subscribe to the feed and follow me on Twitter for more insights and resources!

77 Responses to “Magento – Display new products on the home page”

  1. Comment #1 - Permalink
    rashmi
    05/29/2009

    i have tried what is given above but it does not work. please help.

  2. Comment #2 - Permalink
    Richard
    05/29/2009

    Hello Rashmi,

    Where are you adding it? What version of Magento are you using?

  3. Comment #3 - Permalink
    jennifer
    06/28/2009

    but how to control the number of products display in row and column? Say I want to have 8 new products to display at the main page, with 4 products in a row in 2 columns, is that possible?

  4. Comment #4 - Permalink
    bhuvana
    07/01/2009

    hi

    I placed this above code to CMS->Manage page-> Home page

    bit it does not working

    new.phtml also here catalog/product/

  5. Comment #5 - Permalink
    Eddie
    07/02/2009

    Thanks for the tip re: setting ‘New From Date’.

    Eddie

  6. Comment #6 - Permalink
    layus
    07/03/2009

    Hi Richard,
    I’ve tried the above and it works although, in my template when i set more then 3 products it goes off the table, instead of adding a second row.
    Any ideia how to fix it? I’ve tried to set a limit on css, though it doesn’t seem to work…

  7. Comment #7 - Permalink
    Richard
    07/04/2009

    @Hello bhuvana,

    Are you pasting this into the Content field? This is where you paste it. Also, (Note that you must have some new products in your catalog for anything to show when you do this. This doesn’t mean that you’ve recently added them; only products explicitly marked as new using “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page in the admin tool will be shown.)

  8. Comment #8 - Permalink
    Richard
    07/04/2009

    @Hey Jennifer,

    It sure is! To display 8 items locate the file in your Magento installation (app/code/core/Mage/Catalog/Block/Product/New.php). Make a copy of this. You never want to modify Magento core files.

    What are core files? Files located in app/code/core folder. If you have a need to modify one of them, you need to create a duplicate of that file with the same directory path to app/code/local. So for the New.php file you just made a copy of, copy it to app/code/local/Mage/Catalog/Block/Product/New.php. Now edit the file you just copied and make the following changes:

    Change to the number of products to display:

    const DEFAULT_PRODUCTS_COUNT = 8;
    
  9. Comment #9 - Permalink
    Richard
    07/04/2009

    @Hey Layus,

    Thanks for your comment! The new products are outputted in tables so you can modify the source to suit your needs in /app/design/frontend/default/YOUR_TEMPLATE/template/catalog/product/new.phtml

  10. Comment #10 - Permalink
    Philip
    07/14/2009

    Thanks for this great tip. Works but I am getting the block duplicated. Any ideas why this is happening?
    Philip

  11. Comment #11 - Permalink
    simon browning
    07/18/2009

    Thats a great tip, thank you.

    Would there be a way to get it to show new products from a certain category?

    Thank you.

    Simon

  12. Comment #12 - Permalink
    Richard
    07/19/2009

    @Simon, Sure there is! Just marked the product in the category you want to display as new using “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page.

  13. Comment #13 - Permalink
    Richard
    07/19/2009

    @Philip, Happy this helped you. Check the products that you’ve specified as new.

  14. Comment #14 - Permalink
    simon browning
    07/19/2009

    Hi Richard.

    Thanks for replying.

    What I’d like to do is for example, on the “fruits” page display the newest fruits at the top of the page, followed by the regular fruits category; then on the “vegetables” page, display the newest vegetables at the top of the page, followed by the regular vegetables category.

    Is that possible?

    Thank you.

    Simon

  15. Comment #15 - Permalink
    Plancton
    07/21/2009

    @simon

    If you make a var_dump of your product object variable in your template, you will see there is the category-ids field
    I think you can use it to arrange your products using their category

  16. Comment #16 - Permalink
    Hucks
    07/23/2009

    i set the Set Product as New from Date to yesterday and Set Product as New to Date to tomorrow
    but nothing happens

  17. Comment #17 - Permalink
    Hucks
    07/23/2009

    ok i found the error
    if copying the displayed test its no good. u have to select the icons that pops up by hovering the text with the mousepointer and select the icon “copy to clipboard” then the code is right,

    Tx for the code just what i needed. :)

  18. Comment #18 - Permalink
    Richard
    07/28/2009

    @Hucks
    Try clearing your cache and the Magento cache.

  19. Comment #19 - Permalink
    Liz Lee
    08/07/2009

    This worked great for me. Nice and easy. Thanks!

  20. Comment #20 - Permalink
    zhongzhen
    08/08/2009

    Thanks Richard.
    As I am a magento developer, I am glad to read your post.

  21. Comment #21 - Permalink
    Justin
    08/11/2009

    Hello,

    great write up! It works for me, but I get duplicated blocks, and I don’t know why… Any ideas? It doesn’t matter what product I set up as NEW, still I get duplicated New Product blocks.

  22. Comment #22 - Permalink
    Richard
    08/11/2009

    @Justin, are you sure you have only products explicitly marked as new using “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page in the admin tool will be shown.

  23. Comment #23 - Permalink
    Daniel
    08/18/2009

    Hey Richard, this is great. However, when I put the code in my page, it overlaps my other design, is there a quick way to resize the block? I went into the new.phtml file and I can’t find what I’m lookign for.

  24. Comment #24 - Permalink
    Dan
    08/19/2009

    Scratching my head for a good while trying to get more than 5 latest products to show up, your instructions worked perfectly – THANKS!

  25. Comment #25 - Permalink
    Elizabeth
    08/29/2009

    Thanks for this code. I have it working but with problems. The main problem is that all products are being displayed, even simple products with a “nowhere” display setting. Any suggestions as to how to display only products I’ve chosen to display in my “catalog,search”?

  26. Comment #26 - Permalink
    Richard
    08/29/2009

    @Daniel, You should be able to easily do this with CSS. Have a link for me to see?

  27. Comment #27 - Permalink
    Richard
    08/29/2009

    @Elizabeth, Just mark the product in the category you want to display as new using “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page.

  28. Comment #28 - Permalink
    Elizabeth
    08/29/2009

    Richard, Thanks for your response. I always set these dates — even before I figured out how to diplay new products.

    Here’s what I do and here’s where the problem seems to lie: I start by creating a new, blank “configured” product. I fill in the form including the “Set Product as New from Date” and the “… New to Date.” Then, in “associated products”, I create the various simple products related to the configured product. Now all of the related simple products are set to “enabled” and “nowhere” but they automatically have the dates entered. It sure would be much more convenient for the “new products” function to select only from “catalog,search” enabled products instead of having to manually delete dates from all of my “nowhere” products.

  29. Comment #29 - Permalink
    Rustem
    09/06/2009

    I found the solution. Ok , what should we do to make visible the new products in your website(homepage or else where) :
    Firstly, don’t forget to sign out the product attributes “Set Product as new from date”-”Set Product as new to date”in general information. Try to edit “from date” before today.
    Then if you want to see more than 5 product in your homepage :
    don;t forget about the core: app\code\core\Mage\Catalog\Block\Product\New.php and
    edit the constant: const DEFAULT_PRODUCTS_COUNT = 8;
    This constant respond to how many products will be visible in your page.

  30. Comment #30 - Permalink
    Joanne Carr
    09/07/2009

    Nice post and thread! I seems a lot of people are having problems with the homepage in Magento, which is quite a crucial part of the site! Thanks Richard for all your info on this.

  31. Comment #31 - Permalink
    The PLR Mart
    10/05/2009

    Hi Richard,

    Now its working fine in my site. Thanks for your help.

    The new products title showing as “New Products”, I would like to show as “New Products for October 2009″

    can you please help me out.

    With Regards
    Venkat

  32. Comment #32 - Permalink
    Venkat
    10/06/2009

    Hi Richards,

    It seems you have deleted my comment. I sincerely posted my comment.

    Anyhow i used the code you have mentioned above.

    I have updated the code with 8 products. It is coming in single row and overlapping the right sidebar.

    Help me to show 4 products a row and upto 5 rows please

    site http://www.theplrmart.com

    Regards
    venkat

  33. Comment #33 - Permalink
    Richard
    10/06/2009

    @Venkat, I didn’t delete your comment just didn’t get around to it :) Your most likely going to change the code to do this since it’s in tables. If you eliminate the table layout and replace with divs and a class that’s a floated element, you can display it any way you want.

  34. Comment #34 - Permalink
    Venkat
    10/08/2009

    Hi Richard,

    Thanks for your response. I am sorry to ask you, can you tell me which file i need to change the code in order to display correctly.

    Since i changed the products to 8 first to see 4 products in a row. That time i have right sidebar also, then the 8 products started showing overlay on the right sidebar and its displaying only 5 out of 8 in a single row.

    As you are the expert please help me in this regard

    Thanks in advance

    Venkat

  35. Comment #35 - Permalink
    hucks
    10/26/2009

    cant get it to show more than 4 products

    i have made the categories
    /app/code/local/mage/catalog/block/product
    copyed NEW php to product folder,
    and changed the const DEFAULT_PRODUCTS_COUNT = 5; to const DEFAULT_PRODUCTS_COUNT = 8;

    and updated cache,

    nothing happens ?

  36. Comment #36 - Permalink
    Raqueliii
    10/30/2009

    Hi!
    I have a problem with new products, i search in all answers but is a different problem. I add my products but it doesnt appear in new products, i update the date “Set Product as New from Date ” and ” Set Product as New to Date” and put the date of yesterday i both of them.
    but today when i open the site the products doesnt appear. I dont know why sometimes the products appear and another one disappear. Thxs for all!

  37. Comment #37 - Permalink
    Kalamingo
    10/31/2009

    Hey Richard,

    Was wondering if theres a way to edit the coding, so that it shows the 10 most recently added products to the store without using the new from and to date flag. This will be very useful to me (and many others i would believe) because i dont update my site with new products very often, and lets say i normally flag a products as new for a max period of 7 days, after 8 days this coding wont show any products and my homepage will be lacking content.

    I want it to always show the last 10 products regardless of whether its still flag as new. Hope you can help, thanks in advanced!

  38. Comment #38 - Permalink
    prits
    11/11/2009

    Hi there, I got the new products on home page. But I have problem related to product url. Product url for new products is like http://sitename/catalog/product/view/id/priductID/s/productname and everywhere else it is like “http://sitename/productname.html”.

    Can you please help me on this?

  39. Comment #39 - Permalink
    Adrian
    11/12/2009

    What’s up Richard,

    Wow, I’m really impressed with this, man? I can’t believe you actually take the time to respond to every reply personally. I hope karma is good to you – you deserve it :)

    Just wanted to say thanks for this small but helpful explanation. It has proven essential in a website I was making for someone and you saved me a whole bunch of time trying to reinvent the wheel. Not just your own post, but your replies to further inquiries as well! Thanks so much!

    Keep up the good work man,
    ~Adrian

  40. Comment #40 - Permalink
    Jeannine
    11/12/2009

    Richard, you are a hero! Thank you so much for sharing this with us. I really am so happy to having found a solution to this issue :o )

    Big smile from DK

  41. Comment #41 - Permalink
    Adrian
    11/12/2009

    Hey! A little note: I just noticed this little line in the “new.phtml” (/app/design/frontend/default/YOUR_TEMPLATE/template/catalog/product/new.phtml) of my theme:

    5): continue; endif; ?>

    This would make the loop stop after 5 fragments, even when DEFAULT_PRODUCTS_COUNT is set to any higher variable. I think I saw some people here having problem with this? This might solve their problem :) Hope it helps!

  42. Comment #42 - Permalink
    Adrian
    11/12/2009

    Sorry, apparently that PHP line somehow didn’t make it through your system. Could you fix it in the other comment for me, Richard? You can remove this one afterwards. Thanks!

    The line I was talking about was:

    ~?php if ($i>5): continue; endif; ?~

  43. Comment #43 - Permalink
    gachaga
    11/24/2009

    thank you. it works like a charm. u ve saved me.

  44. Comment #44 - Permalink
    Spenser
    12/05/2009

    This is exactly what I needed for a new build. Thanks so so much for your knowledge!

  45. Comment #45 - Permalink
    Richard
    12/06/2009

    @Spencer Thanks!

  46. Comment #46 - Permalink
    Richard
    12/06/2009

    @gachaga, Thanks!

  47. Comment #47 - Permalink
    Richard
    12/06/2009

    @Jeannine, :)

  48. Comment #48 - Permalink
    Richard
    12/06/2009

    @Adrian, Thanks!

  49. Comment #49 - Permalink
    reeve24
    12/08/2009

    @Richard,
    i just want to say thank you!

  50. Comment #50 - Permalink
    Richard
    12/12/2009

    @reeve24,

    Your welcome! ;)

  51. Comment #51 - Permalink
    Richard
    12/12/2009

    @Raqueliii,

    Did you try clearing your cache?

  52. Comment #52 - Permalink
    Richard
    12/12/2009

    @Kalamingo,

    Sure read this comment (http://www.richardcastera.com/2009/05/21/magento-display-new-products-on-the-home-page/#comment-79)

  53. Comment #53 - Permalink
    Richard
    12/12/2009

    @prits,

    Check your settings for the URL and clear the Magento cache.

  54. Comment #54 - Permalink
    M Atiq Ullah
    12/18/2009

    hello sir I am beginner with magneto. so there is no one that help me . sir tell me that how i can remove the default blocks in magneto home page, like back to school and some others, i us 3 column layout, waiting for ur kind response.

  55. Comment #55 - Permalink
    vaseem ansari
    01/02/2010

    thanks a ton richard above trick worked on mine
    can u help me in below thing.
    i want to create a page so that i can show top 10 best products on click of a link
    if u dont know my e mail by replying to this comment section u can use this vaseem@doomshell.com

    Thanks

  56. Comment #56 - Permalink
    Rajiv
    01/06/2010

    How can I get only the InstockItem only in product collection at New.php for the display in the new.phtml

  57. Comment #57 - Permalink
    Chrisandy
    01/06/2010

    HI Richard and many thanks for some really informative posts.

    I need to do exactly the same as Simon has requested above but cannot find a way to do this despite several days of trying – any ideas would be much appreciated.

  58. Comment #58 - Permalink
    RSQ
    01/27/2010

    Thanks Richard

    grate help

  59. Comment #59 - Permalink
    Richard
    02/16/2010

    @M Atiq Ullah, you can easily achieve this by logging into the back end and go to the CMS home page and change the layout to 1 page layout.

  60. Comment #60 - Permalink
    Richard
    02/16/2010

    @Vaseem, there is a good article on how to do that here, http://inchoo.net/ecommerce/magento/bestseller-products-in-magento/

  61. Comment #61 - Permalink
    michael
    03/08/2010

    hey there,

    With regards to the new products on the homepage, I wanted to know about making 2 rows of 4 instead of the default 3 products showing.

    Thanks in advance for the support

    M

  62. Comment #62 - Permalink
    DS
    03/10/2010

    editing any files to change the products_count value is not necessary
    you just have to set the number of products you want to display via products_count:
    {{block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_homepage” products_count=”40″ template=”catalog/product/new.phtml”}}

  63. Comment #63 - Permalink
    jatinder
    03/10/2010

    i displaying products form new.phtml file on my home page.

    Right now i display only one product [Product Image] on Home Page
    but what i needed is to display random image from Date set [From & To] on each of the products

    So at time the random image will be displayed from product for which date has been set..i want to know a if i set today’s date on my new product and date of tomorrow and other products having date from yesterday to day after tomorrow so which product should display first ?

    can u have your tip on this…

    Thank you…

  64. Comment #64 - Permalink
    Archie
    03/15/2010

    Guys, you don’t need to edit new.phtml to get how many rows you want. in your CMS Page just add column_count=”4″, result will be like this:

    {{block type=”catalog/product_new” name=”home.catalog.product.new” column_count=”4″ alias=”product_homepage” template=”catalog/product/new.phtml”}}

  65. Comment #65 - Permalink
    sriraman
    04/05/2010

    How to create a csv file

  66. Comment #66 - Permalink
    sriraman
    04/05/2010

    i would like to display new product image and its description in left navigation of my home page.i dont know how to do…please anyone help me…

  67. Comment #67 - Permalink
    Jagat
    06/04/2010

    Thanks Richard. Came 2 know abt Magento’s Hidden Gem. :)

    Cheers………

  68. Comment #68 - Permalink
    Mukesh Mishra
    06/06/2010

    I have to display 24 new products on home page, I tried all solution provided here, but unable to get sucess, please suggest me appropriate solution.

    I also tried

    {{block type=”catalog/product_new” name=”home.catalog.product.new” column_count=”8″ products_count=”24″ alias=”product_homepage” template=”catalog/product/new.phtml”}} in home page in CMS.
    but it is showing maximum 9 products only.

  69. Comment #69 - Permalink
    Richard
    06/08/2010

    @Jagat, Thanks!

  70. Comment #70 - Permalink
    sriraman
    06/09/2010

    Hi richard,

    i have a media folder which contains the product and categories contents i do have a csv file which contains the product details.
    How to import these to my site please give me a step by step procedure for this process.its little urgent(csv import and export options)

    Thanks
    Sriraman

  71. Comment #71 - Permalink
    babor_7uiu
    06/13/2010

    Great information. Thanks for sharing!

  72. Comment #72 - Permalink
    DR
    06/28/2010

    How can I get products from a different RSS feed to show up. For example, I keep a category of New Releases and use the RSS Feed per category option. So instead of using the “set product from new..” on EVERY item, which I find DOESN’T work when importing from a CSV, can I just use a different category RSS feed, like mentioned above the “new releases” one, to show the products?

  73. Comment #73 - Permalink
    Michelle
    06/30/2010

    After I’ve copied the new.php file to local folders and edited it – should I then post it back into mage?

  74. Comment #74 - Permalink
    stanley
    08/02/2010

    hey richard, how do change the number of columns of products to 3 so that they fit exactly in the homepage. The codes work properly but there are additional lines on the home page. Am very new to magento. thanx a lot!

  75. Comment #75 - Permalink
    stanley
    08/02/2010

    HI richard, how do change the number of columns of products to 3 so that they fit exactly in the homepage. The codes work properly but there are additional lines on the home page. Am very new to magento. thanx a lot!

  76. Comment #76 - Permalink
    vishal lakhani
    08/12/2010

    HI Richard i have done Like this as below video URL
    and as you said also but i cant get Products on home page can you help me?

    http://vimeo.com/1070986
    as i done as above video i get this message on home page
    There are no products matching the selection.

    i have set date setfrom and set to in general still i get this error

    can u help me?

  77. Comment #77 - Permalink
    vishal lakhani
    08/12/2010

    hey after getting Lots of spending time on that i get Solution
    if some 1 is find message like this
    There are no products matching the selection.
    and first check setfrom and settodate fill it
    and then paste this content

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

    i get There are no products matching the selection. because i double quote template so when i removed that double quote then all products are showing of that category

    Hope for some 1 usefull….

It's Your turn

Click here to cancel reply.
You

CAPTCHA Image
CAPTCHA Audio
Refresh Image



About The Author

Richard is a Web Developer currently working for SankyNet. He is available for freelance work. Visit Shifting Ideas for inquiries. Thanks!
  • Premium Email Templates

    Social Profiles

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google
  • GitHub

    Last Tweet

  • Beware the heat-seeking Nerf machine-gun coming to a cubicle near you http://om.ly/svHF #fb
  • Follow me
  • Archives

    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • September 2008
    • August 2008
    • July 2008
    • June 2008
  • Categories

    • AJAX
    • Apache
    • Books
    • Drupal
    • Ecommerce
    • Flash
    • Google
    • Javascript
    • jQuery
    • Magento
    • Marketing
    • Mootools
    • My Thoughts
    • MySQL
    • News
    • Photoshop
    • PHP
    • Prototype
    • SEO
    • Web Resources
    • Wordpress
  • My Favorites

    • 37 Signals
    • Andrew Warner
    • Chris Coyier
    • Chris Shiflett
    • Collis Ta'eed
    • Development Seed
    • Drupal
    • HubSpot
    • James Padolsey
    • Joel On Software
    • John Resig
    • jQuery
    • Kevin Rose
    • Life Hacker
    • Magento
    • Mashable
    • Matt Cutts
    • Matt Ryan
    • MySQL
    • NetTuts
    • Noupe
    • Photoshop Tutorials
    • PHP
    • Smashing Magazine
    • Tech Crunch
    • WoorkUp
    • Wordpress

2010 © Copyright. Richard Castera - All Rights Reserved.

Top