Tuesday, March 13, 2018

Sitecore Experience Commerce - Error: PipelineAbort:Invalid currency

During minion development in Sitecore Experience Commerce, the following error occurred when running the IAddPriceCardPipeline pipeline.
2 00:10:13 ERROR Pipeline completed with error
System.Exception: Error processing block: Management.block.GetCurrencySetById ---> System.ArgumentNullException: Management.block.GetCurrencySetById: The currency set Id cannot be null or empty.
42 00:10:13 WARN CtxMsg.ValidationError.InvalidCurrency: Text=Invalid currency 'NZD'. Valid currencies are ''.|Shopper=[None]|Shop=|Correlation=d68174cf-9976-410d-b15b-0ee1de8ba39c
42 00:10:13 ERROR PipelineAbort:Invalid currency 'NZD'. Valid currencies are ''.
This error traces back to the fact that I was incorrectly passing in the PriceBook parameter. There is no pipeline to get you a price book by name, however the following example will get you a PriceBook entity by name (if it exists). This makes use of the IFindEntitiesInListPipeline pipeline.
var books = (await _findEntitiesPipeline.Run(new FindEntitiesInListArgument(typeof(PriceBook), string.Format(context.GetPolicy<KnownPricingViewsPolicy>().PriceBooks, "BookName"), 0, int.MaxValue), context)).List;
var book = (PriceBook)books.Items.FirstOrDefault();
Hopefully this snippet is able to save someone some time!

No comments:

Post a Comment