Developer forum

Forum » Dynamicweb 10 » Live product info country

Live product info country

Cátia Torego
Reply

Hi,

Doing an API call to get the product info triggers several GetProductsInfo requests, for the requested country, in this case US, but also for DK.

Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GetEcomData ExternalUserId="115" AccessUserCustomerNumber="115" VatCountryCode="US" VatPostingGroup="">...

Request GetProductsInfo sent: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GetEcomData ExternalUserId="Anonymous" AccessUserCustomerNumber="Anonymous" VatCountryCode="DK" VatPostingGroup="">...

Only one language is associated with the products and the request it's only for US. (request.png)
Shouldn't we get just the first one?

DW version: 10.16.0

request.png

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Looks a bit odd.

Can you check if you have this setting activated:

And if not, try to activate it and see if that makes a change?

 
Cátia Torego
Reply

Hi Nicolai,

That setting is already selected, I tried removing it and it didn't make any diference. 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

What is your default currency?

 
Cátia Torego
Reply

It's USD, its the default and the only one in the solution.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Do you use standard live?

Did you enable anonymous live prices?

 
Cátia Torego
Reply

Hi Nicolai,

Yes, it's standard live and anonymous live prices are enabled.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Catia,
it may be related to the Stock level properties. Could you change the parameters in your query so they don't include the Stock properties and check if that would help?
Then maybe try to change the order in the parameters so the prices properties are the first.
BR, Dmitrij

 
Cátia Torego
Reply

Hi Dmitriy,

I tried those changes and still get duplicate requests for both countries.

 
Melissa Borgmann
Melissa Borgmann
Reply

Bumping this one for visibility as this is still an issue on a DW10 site that is coming up on its intended launch date.

Thank you!
- Melissa B.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi,
could you change your query so it sends the parameters in the request Body instead of the query string parameters, so the query in the Postman looks like this:

The JSON text:
{
    "FilledProperties": [
        "Products"
    ],
    "PageSize": 10,   
    "CurrencyCode":"GBP",
    "CountryCode":"GB",
    "ShopId":"SHOP1",
    "LanguageId":"LANG1",
    "ProductSettings": {
    "FilledProperties": [
      "Id", "Number", "Price"
    ]}
}
Then only the pointed properties will be filled in the response.

Also pay attention to what country is set on the logged in user:


The live integration may make additional calls if the information for some of the products was not returned in the response from the ERP.

BR, Dmitrij
 
Cátia Torego
Reply

Hi Dmitriy,

I tried the changes you suggested and unfortunately the result is the same. I still get duplicate requests for both countries.
I also confirmed the user has the correct country, US.
 

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Catia,
what is your solution url? I can look where the problem can be
You can email to dbe@dynamicweb-cms.com
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Catia,
it seems the problem is connected with the queries for the non-existing products on the ERP side.
I have tried this query:
POST: dwapi/ecommerce/products/?RepositoryName=SwiftProducts&QueryName=Products&getproductinfo=true&ShopId=SHOP1&CurrencyId=USD

Body JSON:

{
    "FilledProperties": [
        "Products"
    ],
    "PageSize": 10,
    "Parameters": {"MainProductID": "64509,64507-017"},
    "CurrencyCode":"USD",
    "CountryCode":"US",
    "ShopId":"SHOP1",
    "LanguageId":"LANG1",
    "ProductSettings": {
    "FilledProperties": [
      "Id", "Number", "Price"
    ]}
}
and the response from the ERP side was this: Response GetProductsInfo received: '<?xml version="1.0" encoding="utf-8"?><tables />'.
So that is the problem as there was no product information returned and the system tries to load that information several times.
Can you try to query the products that exist on the ERP side and the correct xml with product information is returned?

BR, Dmitrij
 
Cátia Torego
Reply

Hi Dmitriy,

So if the product doesn't exist, more than one request is made. But why would it try a different VatCountryCode even when there is only one country configured in the solution?
I will try testing with an existing product in the ERP to see if there's a difference, but we might have a mix of cases where the product exists and some where it doesn't.

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Nicolai and Dmitrij,

I might have a workaround for Catia's issue but wanted to share what I am seeing.

Catia was doing a ajax call to the WebApi https://staging-inolex.mydwsite.com/dwapi/docs/index.html?url=/dwapi/api.json#/Commerce%20%3E%20Products/Products_GetAll , the controller does not require bearer token but the controller overrides the UserId property with UserId from the bearer token either way.

 

The issue with the second calls seems to be related to product not existing in ERP, which makes the LiveIntegration StockProvider request the product again. In StockProvider the LiveContext is built and not received from DW as in PriceProvider - https://github.com/dynamicweb/DataIntegration.LiveIntegration/blob/2d8a4280e189b0bc54379edaf92188cf8f211626/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/StockProvider.cs#L15

https://github.com/dynamicweb/DataIntegration.LiveIntegration/blob/2d8a4280e189b0bc54379edaf92188cf8f211626/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Helpers.cs#L275

The LiveIntegration helper to get user from request uses the Decrypt, which does not account for web encoding. Assuming it will be in querystring and not in view model (UserId in viewmodel is integer and not a string).

UserId=1466
Encrypted value "IqTmSqPFZ7A="
Encrypted value in request  "IqTmSqPFZ7A%3D"
This makes LiveIntegration not to be able to load the user when it decrypts the encrypted value in request.

BR Mario

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Mario,
we will look into a problem with several requests for the non-existing ERP products to get it fixed.
For the correct user being used/found in the Live StockProvider and in the Live Product PriceProvider it is needed to pass the bearer token instead of the UserId.
If you do not pass the bearer token then the user is not found for the PriceProvider.
BR, Dmitrij

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Dmitrij,

Even with the bearer token being sent we saw some extra calls being made as anonymous user - I shared the findings in previous comment, seems to be happening only when product does not exist in ERP, then StockProvider is called. StockProvider and PriceProvider LiveContext are different and seems to be when its occuring the extra anonymous call.

BR Mario

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Mario,
you can try to update the Live integration to the latest 10.4.27 version and try to check if the issue with duplicate requests for the non existing products is solved.
BR, Dmitrij

 

You must be logged in to post in the forum