Developer forum

Forum » Integration » ProductDiscountPercent in live integration

ProductDiscountPercent in live integration

Søren Bremholm Jakobsen
Reply

Hi,

i'm trying to get a product discount displayed on a product template and productlist. I'm using live integration version 2.0 on a Rapido/DW 9.5.5 solution. Product discount is returned in the response: <column columnName="ProductDiscountPercent"><![CDATA[50.00]]></column>. But trying to use GetDouble("Ecom:Product.Discount.Percent") either in the productfeed or directly in the product template returns 0. Am I missing a setting in DW or do I use the wrong tag?

Thanks in advance


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Søren,
there is no support of "ProductDiscountPercent" column in the standard Live integration 2.0 code. So it looks like you have added a new custom field "ProductDiscountPercent" that is retruned from the ERP. If yes, then you need to modify the Live integration code to read the value from that field and store it into some of the order line property like Price or UnitPrice.
File Dynamicweb.Ecommerce.LiveIntegration\OrderHandler.cs
ProcessDiscountOrderLine method.
Or implement your own Ecommerce.Orders.OrderLineTemplateExtender where you can set your custom tag with your value.
Regards, Dmitrij

 
Søren Bremholm Jakobsen
Reply

Thanks Dmitrij,

Is it possible to get the latest liveintegration source code - version 2.0.4? currently the latest version on the download section is 2.0.1

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Yes, you can download it from here.
Regards, Dmitrij

 
Søren Bremholm Jakobsen
Reply

Hi Dmitriy,

I have updated the ProcessResponse method in ProductManager.cs in the live integration project to get the 2 customfields from the response. I have added the following code to store values in 2 customfields:

foreach (ProductField pf in ProductField.GetProductFields())
                        {

                            if (pf.SystemName == "DiscountPercentage")
                            {
                                var productDiscountPercent = item.SelectSingleNode($"column [@columnName='ProductDiscountPercent']").InnerText;
                                if (productDiscountPercent != null)
                                {
                                    productInfo[pf.SystemName] = productDiscountPercent;
                                }
                            }
                            if (pf.SystemName == "NetPrice")
                            {
                                var productNetPrice = item.SelectSingleNode($"column [@columnName='ProductNetPrice']").InnerText;
                                if (productNetPrice != null)
                                {
                                    productInfo[pf.SystemName] = productNetPrice;
                                }
                            }
                        }

and i try to get and display the values in either the productfeed or productlistfeed with:

foreach (LoopItem item in GetLoop("CustomFieldValues"))
    {

        if (item.GetString("Product.CustomField.System") == "DiscountPercentage")
        {
            productObject.discountPercent = item.GetString("Product.CustomField.Value.Clean");
        }
        if (item.GetString("Product.CustomField.System") == "NetPrice")
        {
            productObject.netPrice = item.GetString("Product.CustomField.Value.Clean");
        }
    }

but the 2 customfields are empty. Do you have any idears?

best regards

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

Hi Søren,
You probable need to debug and check the Products\ProductProviderBase.cs class FillProductValues method if it is populating the custom fields values into the product.
So try to debug this code and check if it is passed through the first IF statement (as AddProductFieldsToRequest can be OFF or product.ProductFieldValues collection may be empty):
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];
                    }
                }
            }
Regards, Dmitrij

Votes for this answer: 1
 
Søren Bremholm Jakobsen
Reply

Thanks. That was just the hint I needed to fix the issue

 

You must be logged in to post in the forum