private void UpdateAllowedPriceGroups(FieldChange fieldChange, ProductCatalog catalog)
        {
            var priceGroupId = _priceGroupIdToFieldIdMap.FirstOrDefault(x => x.Value == fieldChange.FieldID).Key;
            var priceGroup   = PriceGroup.Get(priceGroupId);

            if (fieldChange.Value == "1")
            {
                catalog.AddAllowedPriceGroup(priceGroup);
            }
            else
            {
                catalog.RemoveAllowedPriceGroup(priceGroup);
            }
        }
Exemplo n.º 2
0
        public static void UpdateProductPricing(this ITemplateBuilder templateBuilder, FieldChange fieldChange, Item item, Product product, int priceGroupId)
        {
            var productPrice = product.ProductPrices.SingleOrDefault(x => x.Price.PriceGroup.PriceGroupId == priceGroupId && x.MinimumQuantity == 1);

            if (productPrice == null)
            {
                productPrice = new ProductPrice()
                {
                    MinimumQuantity = 1,
                    Guid            = Guid.NewGuid(),
                    Product         = product,
                    Price           = new Price()
                    {
                        Amount     = 0m,
                        Guid       = Guid.NewGuid(),
                        PriceGroup = PriceGroup.Get(priceGroupId)
                    }
                };

                product.ProductPrices.Add(productPrice);
            }

            productPrice.Price.Amount = ConvertLocalizedStringToDecimal(fieldChange.Value, Context.Language.CultureInfo);
        }