Developer forum

Forum » Integration » Lazy loading LI prices loads from db

Lazy loading LI prices loads from db

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a site that uses live prices. When I view a list or details price I get the price from the ERP. All good.

When I turn on "Lazy load product info" the prices are loaded lazily (I get a spinner before seeing the price) but then I get the database price, not the LI price. Additionally, the logs don't show any requests. As soon as I turn off the checkbox again, I get the live price again and the logs reflect that request.

What's going on? I've had some other issues for this same site (see my other recent posts), so maybe something is out of whack? 

Imar


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Furthermore, I see it's using the API when lazy loading: 

/dwapi/ecommerce/products/00-555726?UserId=155&LanguageId=EN&CurrencyCode=GBP&CountryCode=GB&ShopId=SHOP10&FilledProperties=Id%2CPrice%2CPriceBeforeDiscount%2CStockLevel%2CVariantInfo%2CNeverOutOfstock%2CPrices&PriceSettings.ShowPricesWithVat=True&PriceSettings.FilledProperties=Price%2CPriceFormatted&getproductinfo=true

Is that expected or could that be where the problem lies?

Imar

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
can you check the browser console if it contains any error information about the problems?
It can look like that:

BR, Dmitrij

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

I can help with that dll if you need it

 

Best Regards,

Nuno Aguiar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I just upgraded to the latest LI version and ran the same test. Same results (DB price, not a live price) but no messges in the console at all. What DLL would be missing? Any other places I can take a look?

Imar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

Please find the attached DLL. It will generate a token for the webapi and store it in a cookie, that is then later used in JS.

 

The first version was generating a new token on every page request, which was clearly bad. This newer version now relies on the cookie living in a cookie, which is generated and updated on that dll.

 

Best Regards,

Nuno Aguiar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I've added the DLL but the results are the same. Check box for Lazy loading on: prices from the backend. Checkbox off: price from Live Integration.

I reviewed the Web API request for the lookup and I can see the Bearer token in the cookie. The token does contain my user ID, so it looks like it should all just work, but it doesn't.

@Nuno: is this DLL yours or an official one?

Imar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

We at DWNA helped develop the Live Integration part of Swift, namely this part where we need to get the webapi token and save it on a cookie and use it later.

  • The templates and JS you came across is official
  • Unlike Rapido, Swift does not have a DLL - so the DLL despite required is not provide (but it's code was validate by the DK team)
    • I believe it's available upon request
  • This dll is for DW9 only
    • It uses a deprecated method for DW10
    • There's no better way in DW9
      (which is why it's not "officially official")

 

It's the dll we use at DWNA for all projects, but we still have our own version of LI (a copy of DW's with a few extra things we use regularly).

 

Do you get a log from LI for the products you are looking for?

 

Nuno

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
that is connected with the user, so if you will enable the Live integration for the Anonymours user then it will query the prices for the Anonymous user at Lazy Load.
To fix that then you need to update the js file for it to be suitable with the dll that Nuno provided (file is called Files\Templates\Designs\Swift\Assets\_src\js\_live-product-info.js):
Commit b552e6a4: Add console error - Repos (azure.com)
Then once it is update it would be needed to run the npm to update the js scripts:
https://github.com/dynamicweb/Swift#install-nodejs-and-build-design
Aftet that I saw the Live integration was making the requests on mine local solution with passing the correct user, but sometimes the token got expired and it then stopped working, so I am still investigating this.
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks guys, that makes sense. @Nuno: can you send me the DLL so I can give it a try?

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Imar,

 

It's in my response from April 29th. Here's the direct link to it https://doc.dynamicweb.com/Files/Files/Forum/Upload/Thread92369/Message92425/Swift.LoginBearerToken.zip

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1

 

You must be logged in to post in the forum