SaaS CMS has officially launched! Learn more now.

How does GetDiscountPrices with multiple items work?


I know GetDiscountPrices can be called with a single item and it evaluates that by creating a virutal cart with only that item in it and then runs the promo engine against that cart, but how does it work when I pass multiple items?

Let's say I pass the method 25 items, does it create 25 carts and run the engine 25 times, thus taking the same amount of time it would take to just call GetDiscountPrices 25 times with each item?

I ask all this becuase we are trying to speed up our search pages where we show up to 25 items at a time and their prices with discounts.



Oct 22, 2019 23:11

Yes, however the cart is created in memory then it would be very fast. GetDiscountedPrices is meant to be used in your scenario. 

Oct 22, 2019 23:22

When we dont run the engine its about 3 to 4 seconds faster (1 second to load compared to 4 or 5 seconds to load).

Would you suggest then that we look at all our discount logic instead to try to speed things up? (We have a lot of discounts, 100+ active campaigns.)

Are there any epi tools to see what discounts might be taking too long to evaluate?

Oct 22, 2019 23:26
Andreas J - Oct 23, 2019 11:23
If you want to measure the performance of promotion evaluations, you could override `PromotionProcessorResolver` and register it in your IoC container. You would then override the method `ResolveForPromotion` and always return a wrapper for the actual promotion processor. The wrapper itself would just have a `Stopwatch` and a call to the actual `Evaluate` method.

There is no epi-specific tools, but you can use just any good .NET profiler (I personally like dotTrace) to find out with is taking time.

Oct 22, 2019 23:29

Okay, thanks Quan.

Oct 22, 2019 23:30
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.