Developer forum

Forum » Integration » Disable live integration of product stock

Disable live integration of product stock

Johan Ulff
Reply

Hi, is it possible to disable the fetch of product stock when using live integration, and only update the live prices? 

We want to map another field from BC to ProductStock in DW and could do it via regular batch import from BC.

 

Regards Johan


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Johan,
no it is not possible to just deactivate it in the Live integration. You could implement your own CustomProductProvider class that implements your custom functionality
and put that dll the site bin folder.
You can look on the Live integration source code Example Project and implent your own CustomProductProvider like it is done in the example project,
you can just override the FillProductValues method: remove the code:
double? newStock = (double?)productInfo["Stock"];
            if (newStock.HasValue && Helpers.IsDifferentStock(product.Stock, newStock.Value))
            {
                product.Stock = newStock.Value;
                Services.Products.Save(product);
                productInfo["Stock"] = null;
            }
And keep the existing code from the base class:
 

double? priceValue = GetPrice(productInfo, quantity);
            var productPrice = product.GetPrice(Common.Context.Currency.Code, Common.Context.Country.Code2); // NOTE accessing the price, will trigger the price provider to kick in
            productPrice.PriceWithoutVAT = priceValue.GetValueOrDefault();

            // Update Product Custom Fields
            if (Settings.Instance.AddProductFieldsToRequest && product.ProductFieldValues.Count > 0)
            {
                foreach (ProductFieldValue pfv in product.ProductFieldValues)
                {
                    if (productInfo.ContainsKey(pfv.ProductField.SystemName))
                    {
                        pfv.Value = productInfo[pfv.ProductField.SystemName];
                    }
                }
            }

Kind regards, Dmitrij

Votes for this answer: 1

 

You must be logged in to post in the forum