public static void AddVariantListPrice(this ImportCatalogEntityResponse sellableItem, decimal sellableItemListPrice, ItemVariationComponent variant)
        {
            if (sellableItemListPrice == 0)
            {
                return;
            }

            var listPricingPolicy = variant.GetPolicy <ListPricingPolicy>();

            listPricingPolicy.AddPrice(new Money("USD", sellableItemListPrice));
        }
Ejemplo n.º 2
0
        private void AddSellableItemPricing(EntityView entityView, SellableItem entity, ItemVariationComponent variation, CommercePipelineExecutionContext context)
        {
            var policy      = context.GetPolicy <KnownCatalogViewsPolicy>();
            var entityView1 = new EntityView
            {
                Name          = policy.SellableItemPricing,
                EntityId      = entityView.EntityId,
                EntityVersion = entityView.EntityVersion,
                ItemId        = variation != null ? variation.Id : string.Empty,
                UiHint        = "Flat"
            };
            var entityView2 = entityView1;
            var entityView3 = new EntityView
            {
                Name          = policy.SellableItemListPricing,
                EntityId      = entityView.EntityId,
                EntityVersion = entityView.EntityVersion,
                ItemId        = variation != null ? variation.Id : string.Empty,
                UiHint        = "Table"
            };
            var entityView4 = entityView3;

            if (entity != null)
            {
                var str = variation != null?variation.GetPolicy <PriceCardPolicy>().PriceCardName : entity.GetPolicy <PriceCardPolicy>().PriceCardName;

                var properties1   = entityView2.Properties;
                var viewProperty1 = new ViewProperty
                {
                    Name       = "PriceCardName",
                    RawValue   = str ?? string.Empty,
                    IsReadOnly = true,
                    IsRequired = false,
                    IsHidden   = false
                };
                properties1.Add(viewProperty1);
                foreach (var price in (variation != null ? variation.GetPolicy <ListPricingPolicy>() : entity.GetPolicy <ListPricingPolicy>()).Prices)
                {
                    var entityView5 = new EntityView
                    {
                        Name     = context.GetPolicy <KnownCatalogViewsPolicy>().Summary,
                        EntityId = entityView.EntityId,
                        ItemId   = (variation != null ? variation.Id : string.Empty) + "|" + price.CurrencyCode,
                        UiHint   = "Flat"
                    };
                    var entityView6   = entityView5;
                    var properties2   = entityView6.Properties;
                    var viewProperty2 = new ViewProperty
                    {
                        Name     = "Currency",
                        RawValue = price.CurrencyCode
                    };
                    properties2.Add(viewProperty2);
                    var properties3   = entityView6.Properties;
                    var viewProperty3 = new ViewProperty
                    {
                        Name     = "ListPrice",
                        RawValue = price.Amount
                    };
                    properties3.Add(viewProperty3);
                    entityView4.ChildViews.Add(entityView6);
                }
            }
            entityView2.ChildViews.Add(entityView4);
            entityView.ChildViews.Add(entityView2);
        }