Developer forum

Forum » Integration » Using index results in multiple request (Live Integration)

Using index results in multiple request (Live Integration)

Lars Larsen
Reply

Hi

I am having a performance issue when using the Live Integration and the new index to retrieve products from the product catalog module. When requesting a list of products from a product catalog that is set to use a repository index, the Live Integration project creates one request for each product in the requested productlist! This takes much to long time to retrieve from the Dynamicweb Connector/Navision. But if I use the Product Catalog module setting "Product groups" the Live Integration project creates one request for all the requested products. The response for this request is much faster retrieved from the Dynamicweb Connector/Navision. The problem seems to be that when the Product Catalog is set to use a repository index it does not send the notification "ProductListBeforeSort" before the FindPrice method from the Dynamicweb.eCommerce.Prices.PriceProvider is triggered. The FindPrice method is overriden in the Live Integration project and the method receives not a list of products but one single product and the Live Integration project creates one request for that product each time it is called. Therefore a productlist takes much to long to render! Shouldn't the Product Catalog module send the notification "ProductListBeforeSort" before the FindPrice method is triggered when using a repository index to show the products?


Replies

 
Jonas Krarup Dam
Reply

Hi Lars,

It seems that you have spotted a bug in the catalog with the new indexing.

you can solve it yourself by adding a call to PreparePrices from "BeforeSort" notification subscriber, if you are in a hurry.

I will register it as a bug and have it fixed in an upcomming hotfix.

This thread will be updated when the hotfix is out.

 
Lars Larsen
Reply

Hi Jonas

Thank for your swift reply. But I am not sure I understand your suggested work-around. The notification subscriber "ProductListBeforeSort" is called after FindPrice in Dynamicweb.eCommerce.LiveIntegration.PrepareProductInfoProvider. It's in the overridden FindPrice that the products are retrieved one by one from NAV. So adding a call to PreparePrices from "ProductListBeforeSort" will just retrieve all requested products from the cache because the products have already been retrieved one by one from FindPrice.

 
Jonas Krarup Dam
Reply
This post has been marked as an answer

Hi Lars,

Ah, right - I think i got the order the wrong way 'round.

In that case, you will probably have to wait for the hotfix. I have pushed it to the front of the line, so it should be in a hotfix early next week (hopefully already monday).

/Jonas

Votes for this answer: 1
 
Lars Larsen
Reply

Hi Jonas

Ok, sounds good with a hot fix early next week :-)
Thanks

 
Kristian Kirkholt
Reply

Hi Lars

Problem regarding PreparePrices is not called correctly when using product catalog with new indexing.

Has now been resolved in Dynamicweb version 8.6.1.13

You are able to find this build in the download section:

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 
Lars Larsen
Reply

Hi 

I have downloaded v8.6.1.13 and the problem is still there. It seems like nothing has changed. I can still reproduce the error. FindPrice is still called before the notification subscriber "ProductListBeforeSort" resulting in multiple requests to NAV.

 
Morten Snedker
Reply

Hi Lars,

Upgrading the Dynamicweb version is not enough. The method of resolving as described by Jonas, will require changes in the Live Integration source code as well (as this is from where the notifications are triggered). Have these changes been performed?

 

/Snedker

 
Lars Larsen
Reply

Hi Morten

The method of resolving described by Jonas doesn't work as far as I can see. The notification "BeforeSort" is still called after the overriden method "FindPrice" (in the Live Integration project) has been called. According to the stacktrace attached below "FindPrice" is triggered by "External code" which in this case is Dynamicweb. I presume that it's the product catalog module. Therefore I can't see how I can fix this issue! Any suggestions are really appreciated.

Capture.PNG
 
Lars Larsen
Reply

Hi Morten

I have done some debugging and investigated the debug information from rendering a product list. Here you can see that the text "Get products from Query" (outputted from "Dynamicweb.eCommerce.Frontend.Frontend.GetProductsFromIndexQuery()") is outputted, then "Overriding FindPrice" (a debug text I output from the Live Integration project) and finally the text "Products found, list" which is outputted just before the notification "BeforeSort" (outputted from "Dynamicweb.eCommerce.Frontend.Frontend.ListProducts()")

Capture.PNG
 
Jonas Krarup Dam
Reply

Hi Lars,

I am trying to recreate the problem on my solution - I'll get  back to you as soon as I know more.

 

/Jonas

 
Jonas Krarup Dam
Reply

Hi Lars,

I have tried setting up an integrated website with a simple product  catalog based on the new indexing, and I'm not seeing all the calls to "findPrice".

On my newly created solution, I am getting the calls in the "correct" order, where "onBeforeListSort" is fired before findPrice is called, so it seems that this is not a general problem.

Which solution are you working on here?

It seems that something on your solution is causing a problem, and I have no idea what :-(

 

/Jonas

 

 
Lars Larsen
Reply

Hi Jonas

I am working on http://motostore.dis-play.dk. Would you like to see the code? I can send it and the database to you.

/Lars

 
Jonas Krarup Dam
Reply

Hi Lars,

In the first stack trace you show, there are two "external code" lines. Can you rightclick on those, and "show code", to give us some idea of why findPrice is being called before the notification?

 

/Jonas

 
Lars Larsen
Reply

Hi Jonas

Sure here it is :-)

Capture.PNG
 
Jonas Krarup Dam
Reply

It looks like you have some custom code that is causing this call to findPrice - basically, findPrice is called when a product.Price attribute is accessed, and if you do that in a control that is being rendered before the product catalog, it will result in the extra calls.

I'm not sure what you are doing in the DisPlay.DW.Nellemann.Presentation.dll, but if you are working with the products that are being shown in the product catalog, that might be causing the problems.

if you do, and you have the product collection that is being displayed, you can add a call to FetchProductInfos(List<Product> products), which is in the PrepareProductInfoHandler, before working with the products, in order to force the fetching of products to be done in one call to NAV.

Could this be the cause of the problems?

/Jonas

 
Lars Larsen
Reply

Hi Jonas

I have stipped down my project to only having the overriding method FindPrice. And still it it triggered by the product catalog before the notification "BeforeSort". I have refactored your code and found that product.Price.Price is called from Dynamicweb.eCommerce.Products.ProductCollection.ReFactorProductList() (also in the stacktrace) which is initially called from the product catalog module. But product.Price.Price in ReFactorProductList() is only called if some GlobalSetting settings have certain values. My settings are as follows: 
/Globalsettings/Ecom/Product/DontShowProductIfHasNoPrice = True
/Globalsettings/Ecom/Product/DontShowProductIfNotOnStock = False
/Globalsettings/Ecom/Assortments/UseAssortments = False

with those settings product.Price.Price is called and FindPrice is triggered. If I change /Globalsettings/Ecom/Product/DontShowProductIfHasNoPrice to False FindPrice is called after "BeforeSort".

PS. Display.DW.Nellemann.Presentation.dll is my custom modules dll

/Lars

Capture.PNG
 
Jonas Krarup Dam
Reply

Progress!

after changing the DontShowProductIfHasNoPrice setting, I am seeing the same problem on my test-solution.
 

I'll investigate and get back to you, probably tomorrow before noon.

 

/Jonas

 
Jonas Krarup Dam
Reply

Hi Lars,

After sleeping on this, I have a question: are you sure you want to have "DontShowProductIfHasNoPrice= True?

First of all, setting it to false will solve the problem you are seeing here.

Second, if you have it set to true, you will be sending a lot more requests to NAV, since we have to check with NAV to find out if a given product has a price - I believe that this will cause more traffic between your DW installation and NAV, which probably isn't desirable.

I will continue to investigate, but I think you should consider setting it to "false" and finding a different way to filter out the products that you do not wish to display.

/Jonas

 
Lars Larsen
Reply

Hi Jonas

Your'e right about your thoughts. But I don't want to show products without a price. So I have to deal with this issue anyway. Why not test if Live Integration is active in general and active for the current user in Dynamicweb.eCommerce.Products.ProductCollection.ReFactorProductList() and if they both are then don't call product.Price.Price. And then let the Live Integration project do the refactoring of the product list before the call to NAV. In this way this error we have spend so much time to debug will not happen again, which it will when some one sets /Globalsettings/Ecom/Product/DontShowProductIfHasNoPrice = True on a solution that's using the Live Integration project.

/Lars

 
Jonas Krarup Dam
Reply
This post has been marked as an answer

Hi Lars,

I have investigated further, and talked to Jeppe.

The "DontShowProductIfHasNoPrice" setting cannot work with the new index. If you need to limit which products are shown based on prices/activeStatus/stockStatus, etc, you should do this filtering as part of your search.

Otherwise, paging will not work, and you will end up with irregular product counts on your product pages.

The fact that the checkbox has an effect when using the new index is a mistake on our part, and it is being changed.

I don't see a way to filter which products should be shown, based on current information in NAV - I recommend that you synchronize the information that you need for filtering to the DW database instead.

Regards, Jonas

Votes for this answer: 1
 
Lars Larsen
Reply

Hi Jonas

Thank for your reply. Synchronizing NAV information to the DW database is not an option in my case, because I need live prices in the frontend. I will think about how we now will handle products without a price.

/Lars

 
Jonas Krarup Dam
Reply

Hi Lars,

You can still synchronize a "reference price" or synchronize active/inactive settings to the DW database, and then use that information in the DW database to do filtering. Maybe this is a solution?

/Jonas

 

 
Lars Larsen
Reply

 

Hi Jonas

Yeah, your'e right maybe that is a solution.

/Lars

 

You must be logged in to post in the forum