Developer forum

Forum » Development » HandlePricesExclusively not taken into account in Viewmodel

HandlePricesExclusively not taken into account in Viewmodel

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

We see a performance penalty when using the product viewmodel as the property HandlePricesExclusively in our custom PriceProviders are not respected. Please see the code marked with red here:

        private List<PriceListViewModel> GetPrices(PriceViewModelSettings settings, IList<Product> products, ref bool pricesHasBeenPrepared, object @lock, Product product)
        {
            var context = settings.GetPriceContext();

            PreparePrices(context, ref pricesHasBeenPrepared, @lock, products);

            var prices = product.Prices.Where(price => DefaultPriceProvider.ShowPrice(price, context, product, false));

            var result = new List<PriceListViewModel>(
                prices.Select(price =>
                {
                    var priceRaw = new PriceRaw(price.Amount, price.Currency) { PriceSource = PriceSource.PriceMatrix };
                    var calculated = PriceCalculated.Create(context, priceRaw, product);
                    if (price.IsWithVat && !PriceHelper.PricesInDatabaseIncludeVat)
                    {
                        calculated.RawPriceIncludesVat = true;
                    }
                    calculated.Calculate();

                    return new PriceListViewModel()
                    {
                        Quantity = price.Quantity,
                        Price = CreateView(settings, calculated)
                    };
                })
            );

            return result;
        }

 

Hope it can be adjusted?

 

Best regards, Anders


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Anders

That method is only used for one property ProductViewmodel.Prices which is there to get a list of prices in the database. The price, priceinformative and discount all respect the handleexclusive property.

The price provider does not have an overload for getting "potential prices" which is what the ProductViewmodel.Prices property exposes - i.e. the price you would get if you buy more quantities. We are looking into supporting that on the priceprovider currently though.

So question is what you would expect this to return instead - currently the alternative is returning an empty collection - until we get an extension for the priceprovider that can take over.

The code will not execute if you do not use the ProductViewmodel.Prices property as it is lazy.

Please ellaborate.

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

Yes for now, where an implementation does not exists and I have marked this one: HandlePricesExclusively, then I will expect it to return an empty collection.

 

Best regards, Anders

 

You must be logged in to post in the forum