Display "NEW" label for new products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi,

In the list of products I would like to see a label "NEW" for each new product.
What would be the best way to achieve this? AFAIK there is no date created field I can use in the ProductModel.
I want to change the nopCommerce code as little as possible because I want to be able to update when necessary.

Thanks in advance.


Kind regards,

Rob.
12 years ago
bump
12 years ago
We have done this on www.timetowatch.nl like this:
1. Add a Literal to the product template (.ascx) and call it litSpotlight.
2. Add the below code to the BindProductInfo method.

            if (ProductService.GetRecentlyAddedProducts(30).Contains(product))
            {
                litSpotlight.Text = "<div class=\"spotlight-new\"></div>";
            }
            else if (product.ProductVariants[0].OldPrice > product.ProductVariants[0].Price)
            {
                litSpotlight.Text = "<div class=\"spotlight-sale\"></div>";
            }
            else
            {
                litSpotlight.Text = string.Empty;
            }


This will get the last 30 added products and see if the current product is one of them.
If it is recently added, the it will add a DIV with class 'spotlight-new' to the HTML.
If it is not recently added, but is on sale, it will add a DIV 'spotlight-sale' to the HTML.

BTW: this is done in nop 1.90.

It's up to you how the DIV looks like. Just add the right classes to the CSS file.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.