Exemplo n.º 1
0
        public async Task <string> GetCategoryPath(CommerceContext commerceContext, string categoryCommerceId)
        {
            Category category = await getCategoryCommand.Process(commerceContext, categoryCommerceId);

            if (category == null)
            {
                return(categoryCommerceId);
            }

            string parentPath = await GetParentPath(commerceContext, category.ParentCategoryList, string.Empty);

            return($"{parentPath}/{category.DisplayName}");
        }
Exemplo n.º 2
0
        public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            CommerceContext commerceContext = context.CommerceContext;

            IEnumerable <EntityView> results = arg.ChildViews.OfType <EntityView>()
                                               .Where(
                x => x.ItemId.IndexOf("-Category", StringComparison.OrdinalIgnoreCase) > 0);

            foreach (EntityView result in results)
            {
                ViewProperty displayProperty =
                    result.Properties.FirstOrDefault(x => x.Name.EqualsOrdinalIgnoreCase("DisplayName"));
                if (displayProperty == null)
                {
                    continue;
                }

                Category category = await _getCommand.Process(commerceContext, result.ItemId);

                if (category == null)
                {
                    continue;
                }

                string parentPath =
                    await categoryPathResolver.GetParentPath(commerceContext, category.ParentCategoryList,
                                                             string.Empty);

                if (parentPath.Length > 0)
                {
                    displayProperty.Value = $"{category.DisplayName} in {parentPath}";
                }
                else
                {
                    displayProperty.Value = category.DisplayName;
                }
            }

            return(arg);
        }
Exemplo n.º 3
0
        private async Task <string> GetSitecoreIdFromCommerceId(CommerceContext commerceContext, string categoryCommerceId)
        {
            Category category = await getCategoryCommand.Process(commerceContext, categoryCommerceId);

            return(category?.SitecoreId);
        }