Exemple #1
0
        private MSCommerceCatalogCollection2CatalogCategory[] GenerateCategories()
        {
            List <MSCommerceCatalogCollection2CatalogCategory> categories = new List <MSCommerceCatalogCollection2CatalogCategory>();

            var prefixesToExclude = Configuration.CategoryPrefixesToExclude.Split(',')
                                    .ToList();



            var dataTable  = stagingRepository.ReadParentCategories();
            var childTable = stagingRepository.ReadSubCategories();

            foreach (DataRow cat in dataTable.Rows)
            {
                var newSubCat = new MSCommerceCatalogCollection2CatalogCategory()
                {
                    name = cat.GetString("CategoryId"), Definition = "Category"
                };
                newSubCat.DisplayName = CreateDisplayName(cat.GetString("CategoryName"));
                categories.Add(newSubCat);
            }

            foreach (DataRow subCat in childTable.Rows)
            {
                if (prefixesToExclude.Contains(subCat.GetString("CategoryId")
                                               .Substring(0, 2)))
                {
                    continue;
                }

                var newSubCat = new MSCommerceCatalogCollection2CatalogCategory()
                {
                    name = subCat.GetString("CategoryId"), Definition = "Category"
                };
                newSubCat.DisplayName    = CreateDisplayName(subCat.GetString("CategoryName"));
                newSubCat.ParentCategory = new ParentCategory[1] {
                    new ParentCategory()
                    {
                        Value = string.Format("{0}000", subCat.GetString("CategoryId", true)
                                              .Substring(0, 2))
                    }
                };
                categories.Add(newSubCat);
            }

            return(categories.ToArray());
        }
Exemple #2
0
        private MSCommerceCatalogCollection2CatalogCategory[] GenerateUNFIEastCategories()
        {
            List <MSCommerceCatalogCollection2CatalogCategory> categories = new List <MSCommerceCatalogCollection2CatalogCategory>();

            var prefixesToExclude = Configuration.CategoryPrefixesToExclude.Split(',')
                                    .ToList();



            var      dataTable        = stagingRepository.ReadUNFIEastItems();
            DataView dataView         = new DataView(dataTable);
            var      parentCategories = dataView.ToTable(true, "Category");
            var      childCategories  = dataView.ToTable(true, "Category", "Subgroup");

            foreach (DataRow cat in parentCategories.Rows)
            {
                var newSubCat = new MSCommerceCatalogCollection2CatalogCategory()
                {
                    name = cat.GetString("Category"), Definition = "Category"
                };
                newSubCat.DisplayName = CreateDisplayName(cat.GetString("Category"));
                categories.Add(newSubCat);
            }

            foreach (DataRow subCat in childCategories.Rows)
            {
                var newSubCat = new MSCommerceCatalogCollection2CatalogCategory()
                {
                    name = subCat.GetString("Subgroup"), Definition = "Category"
                };
                newSubCat.DisplayName    = CreateDisplayName(subCat.GetString("Subgroup"));
                newSubCat.ParentCategory = new ParentCategory[1] {
                    new ParentCategory()
                    {
                        Value = subCat.GetString("Category")
                    }
                };
                categories.Add(newSubCat);
            }

            return(categories.ToArray());
        }