I am trying to Preparing prices for multiple products here, I am following this post here:
http://developer.dynamicweb-cms.com/documentation-8.0/for-developers/%28moved%29-ecommerce/%28moved%29-extensibility/providers/price-providers.aspx
And having some difficulties with "MyPriceProviderCache" see the example below.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Dynamicweb.eCommerce.Prices; using Dynamicweb.Extensibility; using Dynamicweb.Frontend; using System.Data.SqlClient; using Dynamicweb.eCommerce.Products; public class CustomDiscountPriceProvider : PriceProvider { public override void PreparePrices(ProductCollection Products) { // Fetch prices from the external system using a mock connector Dictionary<string, double> productPrices = FindPricesHelper(Products); // Clear old cache if (HttpContext.Current.Items.Contains("MyPriceProviderCache")) HttpContext.Current.Items.Remove("MyPriceProviderCache"); // Put new prices into cache HttpContext.Current.Items.Add("MyPriceProviderCache", productPrices); } private Dictionary<string, double> FindPricesHelper(ProductCollection Products) { Dictionary<string, double> returnProductPriceCombo = new Dictionary<string, double>(); foreach (Product p in Products) { returnProductPriceCombo.Add(p.ID, 100); } return returnProductPriceCombo; } }
What I basically want to do here, is that I want to set all products the same price no mater what. Simply 100 DKK before tax.
But that does not seem to work for some reason. No exception, just prices cannot be assigned to their products...
I feel it's cause MyPriceProviderCache or do I still also have to override this:
public override PriceRaw FindPrice(Dynamicweb.eCommerce.Products.Product Product, double Quantity, string VariantID, Dynamicweb.eCommerce.International.Currency Currency, string UnitID, Dynamicweb.Frontend.Extranet User)
Any suggestions?
Regards,
Dmitrij