Fetching Prices from API directly to show in frontend causes performance problem in b2b site

We have a requirement to fetch prices directly from api for b2b site. But calling method to fetch price from api for a every variant to be listed on product listing page is affecting the performance of the page.

We have an api in jeeves that fetches prices of different variants based on the variant ids we provide.

I know the pricecalculatordecorator is being called for each variant.

Can you suggest the best way to use pricing from api for the variants displayed on b2b frontend.

Litium version: [7.6.0]

You can send in an array of

var calculatorItemArgs = new PriceCalculatorItemArgs
{
     VariantSystemId = variantSystemId,
      Quantity = decimal.One
 };

to

var prices = _priceCalculator.GetListPrices(calculatorArgs, calculatorItemArgsArray)

And then you get back multiple prices that you can collect and send back.

prices.TryGetValue(variantSystemId, out var price) // Save values here in an array and send back.

Then you only call PriceCalculator once, and you only need 1 call from Jeeves.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.