Update prices properly in Episerver Commerce
Examples and valuable information about the price apis.
Published 30 nov 2020
Episerver Commerce 13
First of all, if you are working with Episerver Commerce, you should buy and read the ultimate guide Pro Episerver Commerce by Quan Mai (awesome guide with example of all parts of Episerver Commerce)
Thank you Quan Mai for these take aways!
Updating Prices
Pretty normal scenario is to have a scheduled job updating prices with for example updated prices or campaigns.
IPriceService
Did you know this?
- IPriceService is optimized for batch processing
- You save all prices of a SKU
- It optimizes prices before saving
- It reorders and sorts the prices in database table
- The prises are ordered by period, price and min quantity
- If there are overlapped periods, the lowest price will win
- Higher prices can be removed
- Prices time periods can be changed
Note: You may use IPriceDetailService to save prices as is, with no optimization, no cache, and it syncs well with IPriceService.
Use of CustomerPricing
You might have different prices for markets or currencies for an SKU, but you might also want to have different prices for different customers (or types of customers).
Quan Mai 2018 (Pro Episerver Commerce by Quan Mai – page 83 )
Sale Type and Sale Code could be used to list “Manufacturer suggested retail price” (MSRP) for display to user in front-end. In “Pro Episerver Commerce” page 90 you find a detailed example how to implement such.
Code sample batch saving price from ERP
In this sample i use salescode on CustomerPricing to name the different campaigns.
At the end i batch save all prices at once.
About the author
Luc Gosso
– Independent Senior Web Developer
working with Azure and Episerver
Twitter: @LucGosso
LinkedIn: linkedin.com/in/luc-gosso/
Github: github.com/lucgosso