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) allPromotions.AddRange(_contentLoader.GetChildren<PromotionData>(salesCampaign.ContentLink));
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
PromotionEngineContentLoader.GetPromotions should do that for you. But if you want to write some code yourself, then Joel's answer is correct.
Isn't that one internal? Reason I didn't recommend it is that I thought it was internal :P
https://world.episerver.com/documentation/class-library/?documentId=commerce/9/16DE8B32
Hi,
I know how to retrieve one promotion (using IContentLoader)... But, how can I easily get a collection of ALL promotions at runtime?
Thanks,
- Ken