Try our conversational search powered by Generative AI!

Best way to find ALL promotions?



I know how to retrieve one promotion (using IContentLoader)... But, how can I easily get a collection of ALL promotions at runtime?


 - Ken

Edited, Oct 17, 2017 22:09

Using the same APIs. Discounts (=promotions) are children of Campaigns (or SalesCampaigns). And you cannot create a SalesCampaign with another SalesCampaign as parent, hence it's only two levels. So just interate all the campaigns and then get the children of all of them. Like so

var salesCampaigns = _contentLoader.GetChildren<SalesCampaign>(SalesCampaignFolder.CampaignRoot);
var allPromotions = new List<PromotionData>();
foreach (var salesCampaign in salesCampaigns)
Oct 17, 2017 23:05

Ah, I see.  That had crossed my mind after your answer on my other question ;)  But, wasn't sure if it's the preferred way so I decided to ask :)

Thanks again Joel,

 - Ken

Oct 17, 2017 23:14

PromotionEngineContentLoader.GetPromotions should do that for you. But if you want to write some code yourself, then Joel's answer is correct.

Oct 17, 2017 23:23

Sounds good to me!

Oct 17, 2017 23:39

Isn't that one internal? Reason I didn't recommend it is that I thought it was internal :P

Oct 18, 2017 12:43
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.