Developer forum

Forum » Integration » Duplicate live requests for multiple countries

Duplicate live requests for multiple countries

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a site using a recent version of live integration. When logged in I am getting customer specific prices. However, the LI logs show that two requests are made for each product: for two different VAT countries (DK and GB in my case). The site is configured to use GB and so is my user, so I am not sure where that DK is coming from. Even worse, on a list with multiple products, my GB requests are batched but the DK ones go one by one. This means instead of one request, it now makes three when displaying two products.

Here's an example from the logs:

04/23/2024 05:15:04.228 PM: DebugInfo: Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GetEcomData ExternalUserId="202042" AccessUserCustomerNumber="202042" VatCountryCode="DK" VatPostingGroup="">
  <tables>
    <Products type="filter">
      <Product>
        <ProductId>00-556388</ProductId>
        <ProductVariantId/>
        <ProductNumber>00-556388</ProductNumber>
        <ProductUnitId>Unit_EA</ProductUnitId>
        <ProductIdentifier>00-556388..EN</ProductIdentifier>
        <CurrencyCode/>
        <Quantity>1</Quantity>
      </Product>
    </Products>
  </tables>
</GetEcomData>'.
04/23/2024 05:15:04.321 PM: DebugInfo: Response GetProductsInfo received: 'Response here'.
04/23/2024 05:15:04.331 PM: DebugInfo: Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GetEcomData ExternalUserId="202042" AccessUserCustomerNumber="202042" VatCountryCode="DK" VatPostingGroup="">
  <tables>
    <Products type="filter">
      <Product>
        <ProductId>00-570266</ProductId>
        <ProductVariantId/>
        <ProductNumber>00-570266</ProductNumber>
        <ProductUnitId>Unit_EA</ProductUnitId>
        <ProductIdentifier>00-570266..EN</ProductIdentifier>
        <CurrencyCode/>
        <Quantity>1</Quantity>
      </Product>
    </Products>
  </tables>
</GetEcomData>'.
04/23/2024 05:15:04.427 PM: DebugInfo: Response GetProductsInfo received: 'Response here'.
04/23/2024 05:15:04.533 PM: DebugInfo: Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GetEcomData ExternalUserId="202042" AccessUserCustomerNumber="202042" VatCountryCode="GB" VatPostingGroup="">
  <tables>
    <Products type="filter">
      <Product>
        <ProductId>00-556388</ProductId>
        <ProductVariantId/>
        <ProductNumber>00-556388</ProductNumber>
        <ProductUnitId>Unit_EA</ProductUnitId>
        <ProductIdentifier>00-556388..EN</ProductIdentifier>
        <CurrencyCode>GBP</CurrencyCode>
        <Quantity>1</Quantity>
      </Product>
      <Product>
        <ProductId>00-570266</ProductId>
        <ProductVariantId/>
        <ProductNumber>00-570266</ProductNumber>
        <ProductUnitId>Unit_EA</ProductUnitId>
        <ProductIdentifier>00-570266..EN</ProductIdentifier>
        <CurrencyCode>GBP</CurrencyCode>
        <Quantity>1</Quantity>
      </Product>
    </Products>
  </tables>
</GetEcomData>'.
04/23/2024 05:15:04.625 PM: DebugInfo: Response GetProductsInfo received: 'Response here'.

We're running on DW 9.16.2 and LI 7.2.12.0.

What's going on?

Imar


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,

it looks like the Live integration is a bit old, can you try to update to more recent 7.4.*?
That can happen once the country is not found, it is missed for the  finding the Stock level, so it takes first found country for the VatCountryCode attribute.
Can you also try to check if removing/commenting out the Stock tags helps? (If the issue will occur after the Live integration update)
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I see. Will upgrade and test out the stock changes if needed, and then report back here.

Cheers,

Imar

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I upgraded the DLL to the latest and still see the same. Which stock tags to disable are you talking about specifically?

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,

If its a template then those tags are triggering StockLevelProvider:
Ecom:Product.Stock
Ecom:Product.AvailableAmount
"VariantCombinations" loop

If it is a WebApi the those properties:
StockLevel
StockStatus
StockDeliveryText
StockDeliveryValue

What is your solution url? ​
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
there is a new version for the Live integration released: https://www.nuget.org/packages/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/7.4.8
It will use the default currency in the first request which always come from the StockLevelProvider.

The current StockLevelProvider api in DW9 does not provide any other ability to determine the current Currency
So the requests run in this order:
For the Page with product list the first request is oftern made for the first product with StockProvider as a trigger to get its stock (and also a price)
second request is made for the all products that are on the page from the PriceManager.PreparePrices method, next StockProvider calls will use the cached values.
For the one product list there always will be 2 requests

For the one product details page: 1 request if default currency matches the frontend currency, otherwise 2 requests - first for Stock, second for Price (with correct frontend currency)

Now with the new version 7.4.8 if the default currency is the same as your current frontend currency there will be one request for the specific one product details (if you are browsing one product detail page), previously the first request which always comes from the StockLevelProvider was with empty CurrencyCode in the request xml, so that is why the second request was made because it can not determing in which currency the first request was.


BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Something changed with that update but I am not sure if it's better. I now see 50 requests on a page with 50 products, like the following:

<GetEcomData ExternalUserId="202040" AccessUserCustomerNumber="202040" VatCountryCode="DK" VatPostingGroup="">
  <tables>
    <Products type="filter">
      <Product>
        <ProductId>16051259</ProductId>
        <ProductVariantId></ProductVariantId>
        <ProductNumber>16051259</ProductNumber>
        <ProductUnitId>Unit_EA</ProductUnitId>
        <ProductIdentifier>16051259..EN</ProductIdentifier>
        <CurrencyCode>GBP</CurrencyCode>
        <Quantity>1</Quantity>
      </Product>
    </Products>
  </tables>
</GetEcomData>

That's similar to how it was, but now without the one big request with all 50 products. So we went from N+1 to N.

Making so many individual requests is going to kill performance. Can't we change this so it makes a single call for all products on the current page and combines the stock and price lookup in a single request?

Imar

 

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

It combines that, but it needs to call the PriceManager.PreparePrices. So if you don't have any Price tags then the Price manager is not called, so that is why only the StockManager is called causing so much amount of requests. Can you check if you have any Price tags?
Also you add "&debug=true" to the request page and that will give you more details on what subscribers are called and in what order from the LiveIntegration.
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I do have prices on the page; it's a standard Swift product list page. When I log in as a user and browse a catalog page, debug=true first shows me this:

DynamicwebLiveIntegration.StockProvider.FindStockLevel product[id='16051259' variantId=''] START
15:28:21.621 DynamicwebLiveIntegration.ProductManager.FetchProductInfos START
15:28:21.621 DynamicwebLiveIntegration.Connector.GetProductsInfo START
15:28:21.621 DynamicwebLiveIntegration: Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
-- Request XML here
15:28:21.703 DynamicwebLiveIntegration: Response GetProductsInfo received: '<?xml version="1.0" encoding="utf-8"?><tables 
-- Response XML here
15:28:21.703 DynamicwebLiveIntegration.Connector.GetProductsInfo END
15:28:21.703 DynamicwebLiveIntegration.ProductManager.FetchProductInfos END
15:28:21.705 DynamicwebLiveIntegration.StockProvider.FindStockLevel product[id='00-570471' variantId=''] START
15:28:21.705 DynamicwebLiveIntegration.ProductManager.FetchProductInfos START
15:28:21.705 DynamicwebLiveIntegration.Connector.GetProductsInfo START

This gets repeated 50 times. This also contains the (incorrect?) VAT code: VatCountryCode="DK" 

Then after those 50 calls, I get this, again repeated 50 times:

DynamicwebLiveIntegration.ProductPriceProvider.PreparePrices START
15:28:25.939 DynamicwebLiveIntegration.ProductPriceProvider.FindPriceInfoWithContext product[id='16051259' variantId='' unitId='Unit_EA'] START
15:28:25.939 DynamicwebLiveIntegration.ProductPriceProvider.FindPriceInfoWithContext END
15:28:25.939 DynamicwebLiveIntegration.ProductPriceProvider.FindPriceInfoWithContext product[id='00-570471' variantId='' unitId=''] START
15:28:25.939 DynamicwebLiveIntegration.ProductPriceProvider.FindPriceInfoWithContext END

So it seems there's some kind of ordering issue: the stock provider kicks in first and makes 50 calls. The request also contains the price which then (so it seems) is used by the price provider.

What I would like to see is a single request for all 50 products, returning stock and price info.

More info:

1. Latest LI: 7.4.8.0
2. DW 9.16.2
3. The user is logged in
4. We don't have anonymous prices checked in the LI settings
5. The templates have price tags (that is, they output prices which should come from a tag or ViewModel somehow).

Shall I send you the URL to the site and some account info to log in with?

Thanks for your continued support!

 

 

You must be logged in to post in the forum