Posted on 01/06/2021 14:58:15
Hi Jonas
There is no super simple way. Discounts comes in 2 flavors - for products and for orders.
Product discounts are applied before you add to the cart and affects the price displayed to the user on the detail page etc - order discounts are applied to the cart and the discount is applied to the order total.
It seems like you need to display products with a product discount. In DW that is not super simple because all kinds of rules can apply to that discount - i.e. is it the right user, the right date, the right country, language and a range of other things. This is the reason why these discounts are not indexed on the products - that could have been nice.
That is to tell that it is very difficult to create something that can give you all products with a specific discount because of the number of rules and products that could cause heavy performance problems.
So, enough for all the excuses...
What you can do is to create some kind of simple setup that allows you to do something. I.e. create a group called "Promoted discounted products" and add products to that group and when they are there, they can be displayed in a banner or similar.
You might also be able to get information from the DiscountService to find the discount them selves:
Will give you all product discounts:
Dynamicweb.Ecommerce.Services.Discounts.GetActiveOrderLineDiscounts();
Can give you product discounts for a product:
Dynamicweb.Ecommerce.Services.Discounts.GetApplicableDiscountsForProduct("prod1", "vo1", "lang1", Dynamicweb.Ecommerce.Common.Context.Currency, null);
Both methods are cached and should perform nicely.
BR Nicolai