Developer forum

Forum » Development » Prices from Live integration in Schedule Task AddIn

Prices from Live integration in Schedule Task AddIn

Alexandru Aliu
Reply

Hey guys,

I have a project with live integratiom, the prices are fetched from an external system . I developed a scheduled task that generates a custom XML with all the active products. I noticed that some of the products don't have prices in my export, but they do on the website. In order to get the prices, I do this

priceContext = new PriceContext(currency, country);
priceService = new PriceService();
var activeProducts = Services.Products.GetAllProductsWithoutVariants(false, LANGUAGE_ID, false)
                    .Where(i => i.Active);

            foreach (var p in activeProducts)
            {
                var price = p.GetPrice(priceContext).Price;

            }

The question is: does this method return the right price from Live integration ?


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Alexandru

Usual the live integration runs in the context of a user from user management that have a customer number attached to them. In that case, since there is not user, that will not happen in this case. 

The pricecontext do have a Customer property that you can set. Live integration can also be setup to run in anonymous mode.

When you run a schedule there is no http context - and some live integrations have a dependency on sessions, httpcontext and other ugly stuff that might cause them not to run here. But the latest versions of Dynamicweb standard live integration (7.3+) should be able to run out of context.

Also it is possible to use the webapi (/dwapi/docs/ - Products enpoint) to query for products and their live prices.

 

You must be logged in to post in the forum