public void EvaluateProductPrices(IEnumerable <Product> products) { var workContext = _workContextFactory(); //Evaluate products prices var evalContext = products.ToServiceModel(workContext); var pricesResponse = _pricingApi.PricingModuleEvaluatePrices(evalContext); ApplyProductPricesInternal(products, pricesResponse); }
private void LoadProductsPrices(Product[] products) { var result = _pricingModuleApi.PricingModuleEvaluatePrices( evalContextStoreId: _workContext.CurrentStore.Id, evalContextCatalogId: _workContext.CurrentStore.Catalog, evalContextProductIds: products.Select(x => x.Id).ToList(), evalContextCustomerId: _workContext.CurrentCustomer.Id, evalContextCertainDate: _workContext.StorefrontUtcNow, evalContextPricelistIds: _workContext.CurrentPriceListIds.ToList()); foreach (var item in products) { item.Prices = result.Where(x => x.ProductId == item.Id).Select(x => x.ToWebModel()).ToList(); var price = item.Prices.FirstOrDefault(x => x.Currency.Equals(_workContext.CurrentCurrency)); if (price != null) { item.Price = price; } } }