November Happy Hour will be moved to Thursday December 5th.

Create new promotion campaign in initialization module. SalesCampaignFolder.CampaignRoot is null.

Vote:
 

I am trying to create a new campaign for a new promotion in a initialization module, but every time I try to run it, SalesCampaignFolder.CampaignRoot is null. Below is my current code.

_contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
_campaign = _contentRepository.GetDefault<SalesCampaign>(SalesCampaignFolder.CampaignRoot);

Thanks for any help.

#202091
Mar 13, 2019 16:40
Vote:
 

Hi - Make sure your initialization module depends on EPiServer.Commerce.Initialization.InitializationModule 

Inside the context of Initialize(InitializationEngine context), you don't have to use ServiceLocator, use 

context.Locate.Advanced instead 

#202101
Mar 14, 2019 10:09
Vote:
 

Ah I see, I was using the Framework InitializationModule for the module dependency. That seemed to do the trick. Thanks!

#202114
Mar 14, 2019 14:17
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.