Developer forum

Forum » Development » Access to RemoveProductFromCache?

Access to RemoveProductFromCache?

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

We need to update some values on the products when checkout is done, and the update is done in the database, but then values are not refreshed.

Will it be possible to have public access to this method?

        Private Sub RemoveProductFromCache(productId As String, languageId As String, variantId As String)

 

Best regards, Anders


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

Can we have access to this method?

 
Nicolai Pedersen
Reply

Why not get the product from the product service and update the values. Then it will take care of it. 

We are not sure the cache as it is today will persist, so we are not happy about exposing the cache related methods.

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

The case is that we can have 50-100 products in 4 different languages where we need to adjust stock levels for both pieces and boxes, so if doing this through the api we are saving appr. 400 products in CheckoutDoneComplete. I do not think that is a good idea?

 
Nicolai Pedersen
Reply

But that it is not product cache. That would be on unitstock.

You can call Application.KillProducts() if you want. But that will not help you here I think

 
Anders Ebdrup
Anders Ebdrup
Reply

But we need to store the data on the products, so it is the product cache.

If we call Application.KillProducts(), then cache on all products will be removed and I do not think that is good instead of just changed products?

 

Right now we are using our own methods:

    public class Helper
    {
        private static string ProductCacheKeyPrefix = "Product_";                
 
        internal static void RemoveProductFromCache(string productId, string languageId, string variantId)
        {
            Cache.Current.Remove(ProductCacheKey(productId, languageId, variantId));
        }
        private static string ProductCacheKey(string productId, string languageId, string variantId)
        {
            return $"{ProductCacheKeyPrefix}{productId}_{languageId}_{variantId}";
        }
    }

 

You must be logged in to post in the forum