コード例 #1
0
        public override void SetComponent(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity,
                                          VariantDetailsComponent component)
        {
            var variation = entity.GetVariation(entityView.ItemId);

            variation.SetComponent(component);
        }
コード例 #2
0
        public override Task ModifyView(CommercePipelineExecutionContext context, EntityView entityView, SellableItem entity, SellableItemDetailsComponent component)
        {
            var childView = new Sitecore.Commerce.EntityViews.EntityView
            {
                Name          = this.ViewName,
                DisplayName   = this.ViewDisplayName,
                EntityId      = entityView.EntityId,
                EntityVersion = entityView.EntityVersion,
                ItemId        = component.Id
            };

            entityView.ChildViews.Add(childView);

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(SellableItemDetailsComponent.MinQuantity),
                DisplayName = "Min Quantity",
                IsRequired  = false,
                RawValue    = component?.MinQuantity,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(SellableItemDetailsComponent.MaxQuantity),
                DisplayName = "Max Quantity",
                IsRequired  = false,
                RawValue    = component?.MaxQuantity,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(SellableItemDetailsComponent.FeaturedDate),
                DisplayName = "Featured Date",
                IsRequired  = false,
                RawValue    = component?.FeaturedDate,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(SellableItemDetailsComponent.ERPManaged),
                DisplayName = "ERP Managed",
                IsRequired  = false,
                RawValue    = component?.ERPManaged,
                IsReadOnly  = true
            });

            return(Task.CompletedTask);
        }
コード例 #3
0
        public override Task DoAction(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity, VariantDetailsComponent component)
        {
            foreach (var property in entityView.Properties)
            {
                if (property.Name == nameof(VariantDetailsComponent.ERPManaged))
                {
                    component.ERPManaged = bool.Parse(property.Value);
                }

                if (property.Name == nameof(VariantDetailsComponent.PIN))
                {
                    component.PIN = property.Value;
                }

                if (property.Name == nameof(VariantDetailsComponent.Language))
                {
                    component.Language = property.Value;
                }

                if (property.Name == nameof(VariantDetailsComponent.Format))
                {
                    component.Format = property.Value;
                }

                if (property.Name == nameof(VariantDetailsComponent.CanBundle))
                {
                    component.CanBundle = bool.Parse(property.Value);
                }

                if (property.Name == nameof(VariantDetailsComponent.Year))
                {
                    component.Year = property.Value;
                }

                if (property.Name == nameof(VariantDetailsComponent.SortOrder))
                {
                    component.SortOrder = property.Value;
                }
            }

            return(Task.CompletedTask);
        }
コード例 #4
0
        public override async Task ModifyView(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity, VariantDetailsComponent component)
        {
            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.ERPManaged),
                DisplayName = "ERP Managed",
                IsRequired  = false,
                RawValue    = component.ERPManaged
            });

            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.PIN),
                DisplayName = "PIN",
                IsRequired  = false,
                RawValue    = component.PIN
            });

            var languageSelectionsPolicy = new AvailableSelectionsPolicy();

            var selectizeConfig = await this.GetLanguages(context);

            if (selectizeConfig != null)
            {
                languageSelectionsPolicy.List.AddRange(selectizeConfig.Options);
            }

            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Language),
                DisplayName = "Language",
                IsRequired  = false,
                RawValue    = component.Language,
                IsReadOnly  = false,
                UiType      = "Dropdown",
                Policies    = new List <Policy>()
                {
                    languageSelectionsPolicy
                }
            });
            var formatSelectionsPolicy = new AvailableSelectionsPolicy();
            var formatConfig           = await this.GetFormats(context);

            if (formatConfig != null)
            {
                formatSelectionsPolicy.List.AddRange(formatConfig.Options);
            }

            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Format),
                DisplayName = "Format",
                IsRequired  = false,
                RawValue    = component.Format,
                IsReadOnly  = false,
                UiType      = "Dropdown",
                Policies    = new List <Policy>()
                {
                    formatSelectionsPolicy
                }
            });
            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.CanBundle),
                DisplayName = "Can Bundle",
                IsRequired  = false,
                RawValue    = component.CanBundle
            });
            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Year),
                DisplayName = "Year",
                IsRequired  = false,
                RawValue    = component.Year
            });

            entityView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.SortOrder),
                DisplayName = "Sort Order",
                IsRequired  = false,
                RawValue    = component.SortOrder
            });
        }
コード例 #5
0
        public override VariantDetailsComponent GetComponent(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView,
                                                             SellableItem entity)
        {
            var variation = entity.GetVariation(entityView.ItemId);

            return(variation?.GetComponent <VariantDetailsComponent>());
        }
コード例 #6
0
 public override bool ShouldAddAction(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity)
 {
     return(entityView.Name.Equals(nameof(VariantDetailsView)));
 }
コード例 #7
0
        public override bool ShouldViewApply(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity)
        {
            var catalogViewsPolicy = context.GetPolicy <KnownCatalogViewsPolicy>();
            var isConnectView      = entityView.Name.Equals(catalogViewsPolicy.ConnectSellableItem, StringComparison.OrdinalIgnoreCase);

            return(entityView.Name == catalogViewsPolicy.Master || isConnectView);
        }
コード例 #8
0
        public override bool ShouldViewApply(CommercePipelineExecutionContext context, Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity)
        {
            var knownViews = context.GetPolicy <KnownCatalogViewsPolicy>();

            return(entityView.Name == knownViews.Variant || entityView.Name == knownViews.ConnectSellableItem);
        }
コード例 #9
0
        public override async Task ModifyView(CommercePipelineExecutionContext context,
                                              Sitecore.Commerce.EntityViews.EntityView entityView, SellableItem entity, VariantDetailsComponent component)
        {
            var childView = new Sitecore.Commerce.EntityViews.EntityView
            {
                Name          = this.ViewName,
                DisplayName   = this.ViewDisplayName,
                EntityId      = entityView.EntityId,
                EntityVersion = entityView.EntityVersion,
                ItemId        = entityView.ItemId
            };

            entityView.ChildViews.Add(childView);

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.ERPManaged),
                DisplayName = "ERP Managed",
                IsRequired  = false,
                RawValue    = component?.ERPManaged,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.PIN),
                DisplayName = "PIN",
                IsRequired  = false,
                RawValue    = component?.PIN,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Language),
                DisplayName = "Language",
                IsRequired  = false,
                RawValue    = component?.Language,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Format),
                DisplayName = "Format",
                IsRequired  = false,
                RawValue    = component?.Format,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.CanBundle),
                DisplayName = "Can Bundle",
                IsRequired  = false,
                RawValue    = component?.CanBundle,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.Year),
                DisplayName = "Year",
                IsRequired  = false,
                RawValue    = component?.Year,
                IsReadOnly  = true
            });

            childView.Properties.Add(new ViewProperty
            {
                Name        = nameof(VariantDetailsComponent.SortOrder),
                DisplayName = "Sort Order",
                IsRequired  = false,
                RawValue    = component?.SortOrder,
                IsReadOnly  = true
            });
        }