Developer forum

Forum » Integration » Not able to get EcomPrices from LI after upgrade from LI version 7.2.12 to 7.4.x

Not able to get EcomPrices from LI after upgrade from LI version 7.2.12 to 7.4.x

Søren Jakobsen
Reply

Hi community,

i'm having an issue with ecomprices returned from ERP after upgrade og DW version and LI. Below custom code snippet from a Swift productprice template works on LI versions 7.2.5 -> 7.2.12. After an upgrade of DW version to 9.17.7 and LI upgrade to 7.4.9 then the below code does not return any prices. I've tested with LI version 7.4.0 -> 7.4.9. Prices doesn't get returned because GetProductInfo returns NULL.

Is it a bug on LI version 7.4.x or do I need to get the ecomprices differently on new versions of LI?

var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId);
var settings = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration.SettingsManager.GetSettingsByShop(Pageview.Area.EcomShopId);
var user = Pageview.User;
var info = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetProductInfo(prod, settings, user);  //Returns NULL

var prices = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetPrices(info);


Replies

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

Hi Soren,
could you try this code instead (the previous method is obsoleted in the new Live integration):
var user = Pageview.User;
var context = new LiveContext(Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Helpers.GetCurrentCurrency(), user, Services.Shops.GetShop(Pageview.Area.EcomShopId));


var info = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetProductInfo(prod, settings, user, context, null); 
// or this:
var info = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetProductInfo(prod, settings, user, context, prod.UnitId); 


BR, Dmitrij

Votes for this answer: 1
 
Søren Jakobsen
Reply

Thanks Dmitrij,

it worked.

had to change the code abit since I couldn't use Helpers.GetCurrentCurrency() - internal class - so I copied the GetCurrentCurrency() method code to the template:

     var currency = Dynamicweb.Ecommerce.Common.Context.Currency;
    if (currency == null && !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request["CurrencyId"]))
    {
        currency = Services.Currencies.GetCurrency(Dynamicweb.Context.Current.Request["CurrencyId"]);
    }
    var context = new LiveContext(currency, user, Services.Shops.GetShop(Pageview.Area.EcomShopId));
 
    var info = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetProductInfo(prod, settings, user, context, prod.DefaultUnitId);

 

You must be logged in to post in the forum