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.)
i have tried what is given...
i have tried what is given above but it does not work. please help.
Hello Rashmi, Where are you...
Hello Rashmi,
Where are you adding it? What version of Magento are you using?
i try at Magento ver. 1.5.0.1...
i try at Magento ver. 1.5.0.1 but no luck.
but how to control the number...
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?
Hey Jennifer, It sure is! To...
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:
hi I placed this above code...
hi
I placed this above code to CMS->Manage page->Home page
bit it does not working
new.phtml also here catalog/product/
Hello bhuvana, Are you...
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.)
Thanks for the tip re:...
Thanks for the tip re: setting 'New From Date'.
Eddie
Hi Richard, I've tried the...
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 idea how to fix it? I've tried to set a limit on css, though it doesn't seem to work...
Hey Layus, Thanks for your...
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
Thanks for this great tip....
Thanks for this great tip. Works but I am getting the block duplicated. Any ideas why this is happening?
Philip
Philip, Happy this helped...
Philip, Happy this helped you. Check the products that you've specified as new.
That's a great tip, thank...
That's a great tip, thank you.
Would there be a way to get it to show new products from a certain category?
Thank you.
Simon
Simon, Sure there is! Just...
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.
Hi Richard. Thanks for...
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
simon If you make a var_dump...
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
i set the Set Product as New...
i set the Set Product as New from Date to yesterday and Set Product as New to Date to tomorrow
but nothing happens
Hucks, Try clearing your...
Hucks,
Try clearing your cache and the Magento cache.
cant get it to show more than...
cant get it to show more than 4 products
i have made the categories /app/code/local/mage/catalog/block/product copied NEW php to product folder, and changed the
to
and updated cache,
nothing happens?
ok i found the error if...
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.
This worked great for me....
This worked great for me. Nice and easy. Thanks!
Thanks Richard. As I am a...
Thanks Richard.
As I am a magento developer, I am glad to read your post.
Hello, great write up! It...
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.
Justin, are you sure you have...
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.
Hey Richard, this is great. ...
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 looking for.
Daniel, You should be able to...
Daniel, You should be able to easily do this with CSS. Have a link for me to see?
Scratching my head for a good...
Scratching my head for a good while trying to get more than 5 latest products to show up, your instructions worked perfectly - THANKS!
Thanks for this code. I have...
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"?
Elizabeth, Just mark the...
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.
Richard, Thanks for your...
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.
I found the solution. Ok,...
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:
This constant respond to how many products will be visible in your page.
Nice post and thread! I seems...
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.
Hi Richard, Now its working...
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
Hi Richards, It seems you...
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 up to 5 rows please
site www.theplrmart.com
Regards
venkat
Venkat, I didn't delete your...
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.
Hi Richard, Thanks for your...
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
Hi! I have a problem with new...
Hi!
I have a problem with new products, i search in all answers but is a different problem. I add my products but it doesn't 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 doesn't appear. I don't know why sometimes the products appear and another one disappear. Thxs for all!
Raqueliii, Did you try...
Raqueliii,
Did you try clearing your cache?
Hey Richard, Was wondering if...
Hey Richard,
Was wondering if there's 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 don't 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!
Kalamingo, Sure read this...
Kalamingo,
Sure read this comment (http://www.richardcastera.com/blog/magento-display-new-products-on-the-h...)
Hi there, I got the new...
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?
prits, Check your settings...
prits,
Check your settings for the URL and clear the Magento cache.
What's up Richard, Wow, I'm...
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
Adrian, Thanks!...
Adrian, Thanks!
Richard, you are a hero!...
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
)
Big smile from DK
Jeannine,...
Jeannine,
Hey! A little note: I just...
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!
Sorry, apparently that PHP...
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:
thank you. it works like a...
thank you. it works like a charm. you've saved me.
gachaga, Thanks!...
gachaga, Thanks!
Post new comment