3

I am using Minion and i wanted to get the Sitecore item from Minion? I can't add in the policy file. I am using Sitecore 9.0.1 version

Any pipeline or command to use here?

2
  • Hi, What item do you mean? If you want to retreive a Sitecore item from the commerce engine you can use the IGetItemByPathPipeline and IGetItemByIdPipeline pipelines
    – Jonne Kats
    Oct 1, 2018 at 12:48
  • What will be the namespace to get this pipeline?
    – Hussain
    Oct 1, 2018 at 14:32

2 Answers 2

3

You can use:

Sitecore.Commerce.Plugin.Management.IGetItemByIdPipeline

string defaultLanguage = context.GetPolicy<GlobalEnvironmentPolicy>().DefaultLocale;
ItemModelArgument itemModelArgument = new ItemModelArgument("{itemPath}");
itemModelArgument.Language = defaultLanguage;
IEnumerable<ItemModel> itemModels = await _getItemsByPathPipeline.Run(itemModelArgument, context);

Sitecore.Commerce.Plugin.Management.IGetItemsByPathPipeline

string defaultLanguage = context.GetPolicy<GlobalEnvironmentPolicy>().DefaultLocale;
ItemModelArgument itemModelArgument = new ItemModelArgument("{ItemID}");
itemModelArgument.Language = defaultLanguage;
ItemModel itemModel = await _getItemByIdPipeline.Run(itemModelArgument, context);
1
  • SitecoreConnectionManager.GetItemById(context.CommerceContext, "{0A624A7F-B1BC-4923-974F-8EF02FB32D46}", "en");
    – Hussain
    Oct 1, 2018 at 17:27
0

I am using commerce 9 update 3. When i am using IGetItemByIdPipeline, it is returning only default 14 properties but when i use IGetItemByPathPipeline , i get the sitecore item field values also.

I need to get the sitecore fields, So i was able to get the sitecore item in CalculateCartFulfillmentBlock pipeline by adding code shown below.

Make sure to have CommerceCommander __commander context injected into the pipeline block constructor.

ItemModelArgument itemModelArgument = new 
ItemModelArgument("/sitecore/Content/Data/DynamicShippingOptions");
itemModelArgument.Language = defaultLanguage;
ItemModel itemModel = await _commander.Pipeline<IGetItemByPathPipeline>().Run(itemModelArgument, context);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.