Developer forum

Forum » Feature requests » Introduction of ProductItems caching (LoadItemGroupProducts and LoadProductItems)

Introduction of ProductItems caching (LoadItemGroupProducts and LoadProductItems)

Allan Iversen

Hi there!

We are running into perfomance issues when we are using product items on our customer solutions.

The following method loads item group data from DB on every requests.

It would be nice if we could introduce caching of these product data retrieved from:

Dynamicweb.Ecommerce.Products.ProductItem.LoadItemGroupProducts() and Dynamicweb.Ecommerce.Products.ProductItem.LoadProductItems


SQL (from LoadItemGroupProducts):
SELECT EcomProductItems.*, EcomProducts.* FROM EcomProductItems LEFT JOIN EcomGroupProductRelation ON EcomGroupProductRelation.GroupProductRelationGroupID = EcomProductItems.ProductItemBomGroupID LEFT JOIN EcomProducts ON EcomGroupProductRelation.GroupProductRelationProductID = EcomProducts.ProductID WHERE EcomProductItems.ProductItemProductID IN ('PROD117478','PROD124175','PROD2615','PROD118088','PROD114526') AND (EcomProductItems.ProductItemBomGroupID IS NOT NULL AND EcomProductItems.ProductItemBomGroupID <> '') AND (EcomProducts.ProductVariantID IS NULL OR EcomProducts.ProductVariantID = '') ORDER BY EcomProductItems.ProductItemSortOrder, EcomProductItems.ProductItemProductID, EcomProductItems.ProductItemID, EcomGroupProductRelation.GroupProductRelationSorting

Void LoadItemGroupProducts(System.Linq.ILookup`2[System.String,Dynamicweb.Ecommerce.Products.Product], System.String) (Dynamicweb.Ecommerce.dll) in :0
Void LoadProductItems(System.Collections.Generic.IEnumerable`1[Dynamicweb.Ecommerce.Products.Product]) (Dynamicweb.Ecommerce.dll) in :0
System.String ListProducts(Dynamicweb.Ecommerce.Products.ProductCollection, System.String, Boolean) (Dynamicweb.Ecommerce.dll) in :0
System.String GetProductsFromIndexQuery(Dynamicweb.Ecommerce.Frontend.ProductCatalogShowType) (Dynamicweb.Ecommerce.dll) in :0
System.String EcomRender() (Dynamicweb.Ecommerce.dll) in :0
System.String GetContent() (Dynamicweb.Ecommerce.dll) in :0
System.String GetModuleOutput(Dynamicweb.Content.Paragraph, Dynamicweb.Frontend.PageView) (Dynamicweb.dll) in :0
Void RenderParagraph(Dynamicweb.Rendering.Template, Dynamicweb.Frontend.ParagraphViewModel) (Dynamicweb.dll) in :0
System.String RenderParagraph(Dynamicweb.Content.Paragraph, Dynamicweb.Frontend.ContainerInfo) (Dynamicweb.dll) in :0
System.Collections.Generic.IDictionary`2[System.String,System.String] CreateContent(System.Collections.Generic.IList`1[Dynamicweb.Content.Paragraph]) (Dynamicweb.dll) in :0
System.Collections.Generic.IDictionary`2[System.String,System.String] CreateContent(Int32) (Dynamicweb.dll) in :0
Dynamicweb.Frontend.PageViewModel CreateInstance(Dynamicweb.Frontend.PageView) (Dynamicweb.dll) in :0
Void SetPageTemplateValues() (Dynamicweb.dll) in :0
System.String Output() (Dynamicweb.dll) in :0
Void ProcessRequest(System.Web.HttpContext) (Dynamicweb.dll) in :0


Allan Iversen

Anyone? - alternative any ideas how to work around on this?

Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen

Hi Allan

I have asked a developer to look at this and see if it possible to change.

But I notice that you have this on your product list, and it is not a good idea to load this on the product list. You can change the list template to not put BOM info on the list, and this will go away.

Not sure caching is the right approach here as that will potentially give us memory issues on larger solutions.

If we will change this, it will probably be loading all of the Items information for the entire list in stead of one product at a time.

Can you tell a bit more on the use case where you need Item information on the product list?

Allan Iversen

Hi Nicolai,

I am not interested in loading these on the product list - we are not using BOM info on the list - only on the product detail view.

It looks like productCollection.LoadProductItems() is called through Dynamicweb.Ecommerce.Frontend.Frontend.ListProducts even if no BOM info is used.

Am I missing something?

- Allan

Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger

Hi Allan,

I've taken a look at this.

With Dynamicweb 9.7.6 and Dynamicweb 9.8.2, the latest versions of those branches at the time of writing, I've been unable to reproduce the issue. Can you tell me which version you're using?

- Jeppe

Allan Iversen

Hi Jeppe,

Customer solution is running on DW 9.6.11 (Ecommerce v1.6.49.0).

I have taken a look on Ecommerce v1.8.13.0 and still it looks like productCollection.LoadProductItems() is called every time when Dynamicweb.Ecommerce.Frontend.Frontend.ListProducts is called.

Are you able to get "After: LoadProductItems" appended when outputting debug information ?debug=true on product lists?

Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger

Hi Allan,

I must revise my previous statement. My solutions is using an asynchronous product list which is why I didn't see any LoadProductItems entries. That combined with the product details page only loading product items once prompted my response.

It should be possible to change the code to only load product items in case they're needed. We'll discuss internally what the best solution is, and I'll let you know here when we have news.

Sorry for the confusion.

- Jeppe

Allan Iversen

Hi again,

That sounds great - thanks!



You must be logged in to post in the forum