Exemplo n.º 1
0
        private GenericTreeNode <Entity> GetRelationshipsTree(Category category)
        {
            var retVal = new GenericTreeNode <Entity>(category);

            if (!category.Parents.IsNullOrEmpty())
            {
                var parentNode = GetRelationshipsTree(category.Parents.Reverse().First());
                retVal.AddChild(parentNode);
            }
            else
            {
                retVal.AddChild(new GenericTreeNode <Entity>(category.Catalog));
            }
            if (!category.Links.IsNullOrEmpty())
            {
                foreach (var link in category.Links)
                {
                    var node = new GenericTreeNode <Entity>(link.Catalog);
                    if (link.Category != null)
                    {
                        node = GetRelationshipsTree(link.Category);
                    }
                    retVal.AddChild(node);
                }
            }
            return(retVal);
        }
Exemplo n.º 2
0
        private GenericTreeNode <Entity> GetRelationshipsTree(CatalogProduct product)
        {
            var retVal = new GenericTreeNode <Entity>(product);

            if (product.Category != null)
            {
                retVal.AddChild(GetRelationshipsTree(product.Category));
            }
            else
            {
                retVal.AddChild(new GenericTreeNode <Entity>(product.Catalog));
            }

            if (!product.Links.IsNullOrEmpty())
            {
                foreach (var link in product.Links)
                {
                    if (link.Category != null)
                    {
                        retVal.AddChild(GetRelationshipsTree(link.Category));
                    }
                    else
                    {
                        retVal.AddChild(new GenericTreeNode <Entity>(link.Catalog));
                    }
                }
            }
            return(retVal);
        }
Exemplo n.º 3
0
        private GenericTreeNode <Entity> GetRelationshipsTree(CatalogProduct product)
        {
            var retVal = new GenericTreeNode <Entity>(product);

            if (product.Category != null)
            {
                retVal.AddChild(GetRelationshipsTree(product.Category));
            }
            else
            {
                retVal.AddChild(new GenericTreeNode <Entity>(product.Catalog));
            }

            var productLinks = new List <CategoryLink>(product.Links ?? Array.Empty <CategoryLink>());

            // VP-5628: Need to use main product links for the variations
            if (product.MainProduct != null)
            {
                productLinks.AddRange(product.MainProduct.Links ?? Array.Empty <CategoryLink>());
            }

            if (!productLinks.IsNullOrEmpty())
            {
                foreach (var link in productLinks)
                {
                    if (link.Category != null)
                    {
                        retVal.AddChild(GetRelationshipsTree(link.Category));
                    }
                    else
                    {
                        retVal.AddChild(new GenericTreeNode <Entity>(link.Catalog));
                    }
                }
            }
            return(retVal);
        }