Developer forum

Forum » Ecommerce - Standard features » Product cache not updating on purchase

Product cache not updating on purchase

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a site in three languages (DK, EN (default) and DE). I have set "In stock" to be not editable across languages. That all works fine and I can only change stock in English in the backend.

Then when I make a purchase of a product at a quantity of 1 in the DK language, the database is updated for all three records and shows the new, decreased quantity.

However, when I go to the backend and look at the product on the details page, the stock is only decreased in the DK language; both the default (EN) and DE language show the previous stock level. It looks like a cache issue, because when I clear the ProductService memory cache in the backend, the three values are in sync again.

Bug? Should the cache be cleared / updated across all three languages on purchase?

Imar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Imar

Could be a bug...

Just made this change - the commented out line the one replaced by the language loop.

if (result)
                    {
                        foreach (Language language in Services.Languages.GetLanguages())
                        {
                            var productUpdate = Services.Products.GetProductById(product.Id, product.VariantId, language.LanguageId);
                            productUpdate.Stock = Services.Products.GetProductStock(product.Id, product.VariantId, language.LanguageId); ;
                        }
                        
                        //product.Stock = Services.Products.GetProductStock(product.Id, product.VariantId, product.LanguageId);
                    }

Needless to say that this requires some testing.

Votes for this answer: 1
 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Imar

Regarding the product Stock cache. A new fix #16117 has been released in Dynamicweb version 9.16.4

Get this version from the download section: https://doc.dynamicweb.dk/downloads/dynamicweb-9

Kind Regards
Care Support
Kristian Kirkholt

Votes for this answer: 1

 

You must be logged in to post in the forum