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.)

Tags: ,

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

  1. rashmi

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

  2. Richard

    Hello Rashmi,

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

  3. jennifer

    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. bhuvana

    hi

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

    bit it does not working

    new.phtml also here catalog/product/

  5. Eddie

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

    Eddie

  6. layus

    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. Richard

    @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. Richard

    @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. Richard

    @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. Philip

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

  11. simon browning

    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. Richard

    @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. Richard

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

  14. simon browning

    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. Plancton

    @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. Hucks

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

  17. Hucks

    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. Richard

    @Hucks
    Try clearing your cache and the Magento cache.

  19. Liz Lee

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

  20. zhongzhen

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

  21. Justin

    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. Richard

    @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. Daniel

    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. Dan

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

  25. Elizabeth

    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. Richard

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

  27. Richard

    @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. Elizabeth

    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. Rustem

    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. Joanne Carr

    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. The PLR Mart

    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. Venkat

    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. Richard

    @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. Venkat

    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. hucks

    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. Raqueliii

    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. Kalamingo

    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. prits

    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. Adrian

    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. Jeannine

    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. Adrian

    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. Adrian

    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. gachaga

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

  44. Spenser

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

  45. Richard

    @Spencer Thanks!

  46. Richard

    @gachaga, Thanks!

  47. Richard

    @Jeannine, :)

  48. Richard

    @Adrian, Thanks!

  49. reeve24

    @Richard,
    i just want to say thank you!

  50. Richard

    @reeve24,

    Your welcome! ;)

  51. Richard

    @Raqueliii,

    Did you try clearing your cache?

  52. Richard

    @prits,

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

  53. M Atiq Ullah

    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.

  54. vaseem ansari

    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

  55. Rajiv

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

  56. Chrisandy

    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.

  57. RSQ

    Thanks Richard

    grate help

  58. Richard

    @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.

  59. Richard

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

Leave a Reply