Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Functionality to Evaluate promotions on entries


In the new [BETA] Marketing section is is possible to evaluate promotions to an order or cart (IOrderGroup) 

But in the product detail page of our new store we want to display the discounted price for a promotion (if a valid promotion exists)

Is there functionality planned for the PromotionEngine to Evaluate promotions on a Collection or Single instance of a Entry?

May 09, 2016 15:52


Yes, that's what we are working on the upcoming version of Commerce - I would expect it to be released in 1-2 weeks (just don't take my words as promises :) )


May 09, 2016 16:15


Yes, such a functionality available shortly. You will be able to evaluate either a single or a collection of ContentReferences referencing an entry. Those API:s should be included in the next Commerce release.


Per Gunsarfs

May 09, 2016 16:17

Than I will not start Developing this myself. ;)

Thanks for the quick response!

May 09, 2016 16:29

There is now a release out that contains this API, If you give it a try, we welcome any feedback for use cases we might have missed, or that could be handled better.


Per Gunsarfs

May 17, 2016 15:58

I've been working with this and most of it seems to work great. 

I just have one problem. When I target a Campaign to a VisitorGroup, and I run the Evaluate function on the promotionEngine, I get an exception. 

Object reference not set to an instance of an object at EPiServer.Commerce.Marketing.CampaignVisitorGroupFilter.IsInVisitorGroup

This seems to happen because HttpContextBase is null.

In the 'workflows' when added the product to the Cart it all works. 

Jun 16, 2016 16:09

Hi Mark

The visitor group filtering does require an http context, since many of the criteria uses it to evaluate if they match or not. However, if no http context exists, it should not fail with a null reference exception. That is a bug, and I'll register that in our systems.

I wonder, where are you calling these methods from? Is it from somewhere where no http context would exists?

Thanks for the report.


Jun 16, 2016 16:21

I was handling my searchresults Asynchronously, so the code to get the price for the products was called from another thread. 

Jun 16, 2016 16:48

Right, that makes sense.

We'll fix this by simply ignoring any visitor group checks of campaigns/promotions if there is no http context available. In other words, if the check is run in a scenario where there is no http context, no promotions will be skipped because of the current user not belonging to any of the required visitor groups.

Jun 16, 2016 17:14


We have met the issue from a partner that if there's no HttpContext then it should be assumed that no visitor groups match and those campaigns should be excluded. So the behavior of above scenario has changes. Now, we'll excluded all campaigns/promotions if there is no http context available.


Edited, Nov 23, 2016 8:54
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.