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

Strategy for custom PriceService

Vote:
 

We are implementing a custom PriceService to get prices from a service API wich will calculate specific prices for customers based on a set of ERP rules. To get as much performance out of the solution we wish to send all current displayed variants directly to the service and not one by one.

The basic implementation we used for initialization of commerce objects is based on Jonas Bergqvists post: http://world.episerver.com/Blogs/Jonas-Bergqvist/Dates/2013/12/Tutorial-Creating-an-EPiServer-Commerce-site-in-MVC--Part-1/

In the initialization of each VariationContent in ContentViewModelFactory it queries for a price resulting that our service would be called once for each variant we are listing which would affect performance alot.

But I'm not sure how to implement a good solution for this that would make the API usage as effective as possible.

Some of my thoughts:

Disable the setting of price in the ContentviewModelFactory and then in the View displaying the list of Variations query the IPriceService with those variations and read the corresponding price on each variation row. Puts much logic in the View.

Another approach would be to, in the ContentViewModelFactory, create a list of PriceValues with the current variations either as global parameter or as a parameter passed along down to the InitializeVariationContentViewModel and used there to set the correct price.

Anyone else has some tips on how to approach this?

#121622
May 15, 2015 12:56
Vote:
 

Hey,

While this sucks on the first page load.  My understanding is that the calls are cached.  That and you will probably be caching that page using a CDN shouldn't be too bad on following page views.  Have you tried it to see what the performance is like?

Adam

#122100
May 26, 2015 16:58
* 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.