Magento : How to show new products in category list

In any normal e-commerce website, it is a good thing to obviously show which products are new. This way you attract attention of your regular visitors and maybe you sell more and you extend the lifetime customer value. Anyway, it is pretty normal to put these new products in front of others in the catalog, or at least to make them conspicuous.

Although Magento allows you to configure start and end dates for a product in order to show it as new, the default Magento template doesn’t show it. This is the goal of this mini-tutorial : to show you how to show new products among old ones in a category list.

In fact, this is not complicated, you only have to know how to do it. This information I’ve found on this forum (french) doesn’t seem to be well known over the internet, but giving such informations might help a lot improving the Magento Community. Anyway. I’ve summerized it, put it in a real example, and even provided it as a download for lazy developers.

First, in the product page of some product in Magento’s backend, insert starting and ending dates for its newness state. To do a test, put (of course) a date before today’s date, and a date which is later as today’s date.

The code to add to access newness dates of a product is the following :

load($_product->getID())->getNewsFromDate();
$newToDate = Mage::getModel(‘catalog/product’)->load($_product->getID())->getNewsToDate();

// Date and time (now)
$now = date(“Y-m-d H:m:s”);

if($newFromDate < $now && $newToDate > $now) {
echo “nv”;
}
?>

Variables $newFromDate and $newToDate get start and end dates of the active product during the loop. This data is only available if you did insert dates values in your product page. If you don’t see any change when you’ll reload the page, you may have not did this 🙂

The path of the file where to insert this code is named list.phtml is the following (just replace yourtheme by name of the theme you’re using, default is default one) :

/app/design/frontend/default/yourtheme/template/catalog/product/list.phtml

To add code for « list » mode, go to line 47, after this start of loop :

For « grid » mode, go to line 93, after the same code as for « list » mode, or almost.

In both cases, you can place the code wherever you want, as soon it is within the loop. Here is what end of loops look like :

If you followed this tutorial correctly, you should see at list a product with mention « This is new! ». If it doesn’t work, you still can download the file (Magento v1.3.2.4) down this page or ask help in comments of this article!

Ce message est également disponible en : French

19 thoughts on “Magento : How to show new products in category list

  1. Luke P

    Thank you very much, exactly what I was looking for, now I can add a ‘new’ class to any product and style it o customers now it is new, surprised this isn’t a feature ‘out of the box’ really.

    Thanks again, saved me a lot of time and headache!

  2. rajeev

    Hi Guy…I have a question… can you help me with to show categories in a gallery? I have a database with categories and id’s. But do not know how to use PHP to show that info. Is there a tutorial that I can follow..or can you help?

  3. bads928

    You’ve shown up codes for the product category list. Thanks for this it is very useful. You can also check < a href="http://www.magento-developer.net/">Magento Templates.

  4. Tom

    I want to show new products in a CMS page , I can display all the new products just like what you said 。 Thanks a lot ! But I do have a big problem , I found that the Paging place have something wrong , the number of the new product doesn’t equal to the number on the paging place , I don’t know what to do !

  5. Linda06

    This can be done to keep customers more and more potential to visit your site and become the ultimate consumer. Also a feature of Web optimization helps you increase your page rank site, which guarantees a heavy traffic.

    buy Magento theme

  6. men's nike air max 1 premium

    Adam beneficial was not merely the most famous criminal defense the actual 19th century; you has been a Leonardo fordi Vinci the level smart that will happened to transgression his or her vocation. Scotland garage and yard regarded them even as “The Napoleon together with the police arrest populace, there Arthur Conan Doyle obtained another good reputation him: mentor Moriarty. read that right: Adam deserving of experienced been “because your man” which usually portrayed Sherlock Holmes’s greatest opponent in real life,
    men’s nike air max 1 premium http://www.tkrempreendimentos.com.br/airmax90.asp?p=2161

  7. cost of louis vuitton wallet

    Excellent product, the size was exactly as described, the color is same as the picture! The bottom hole came closed, but its simple to open it with scissors! Great, will buy again soon!Nice shoes, but smaller size. I am usually 41 (EU) and I ordered 42, but they are still a bit small. Very fast delivery!

  8. ralph lauren oxford

    The pumps were exactly like in the picture and the delivery was fastIt’s an excellent product. Shoes had a high quality and design! This is my second pair of this high heel shoes, first was pink and now I bought an ivory color! Lovely!!!

  9. hookah in washington dc

    I do not know if it’s just me or if everyone else experiencing problems with your site.
    It appears like some of the written text within your posts are running off the screen. Can someone
    else please provide feedback and let me know if this is happening to them as well?
    This may be a problem with my web browser because I’ve had this happen before.
    Thank you

    my homepage; hookah in washington dc

  10. Bolide Relax

    Beijing News (reporter Liu Yang) Zhao Lei on offer garage replica Hermes Bolide , collusive insurance staff,making use of their going to be the name having to do with going to be the auto transport diy manufacturing false traffic accident 24 and 43 million yuan of insurance fraud,most of them are squandered. Yesterday, Xi

Leave a Reply

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