Пример #1
0
        public static void ProcessCategory(int contentNodeParentId, int categoryParentId, bool deepImport, bool includeProducts, bool test3Only)
        {
            // first make a node for the starting category
            UCategory startingCat = UCategoryRepository.Load(categoryParentId);
            int       nodeId      = CreateCategoryNode(startingCat, contentNodeParentId);

            if (deepImport)
            {
                // now get child nodes for this category
                IList <UCategory> subCats = UCategoryNodesRepository.Load(categoryParentId);

                // loop through each child node and process them as well
                foreach (UCategory cat in subCats)
                {
                    ProcessCategory(nodeId, cat.CategoryId, deepImport, includeProducts, test3Only);
                }
            }

            // no more categories to process for this level.
            // Start processing products in this level
            if (includeProducts)
            {
                IList <UProduct> products = UCategoryProductRepository.LoadAll(startingCat.CategoryId);

                int badSkuCounter = 1;
                int prodCounter   = 0;
                // process each product for this category
                foreach (UProduct product in products)
                {
                    if (string.IsNullOrEmpty(product.Sku))
                    {
                        product.Sku = string.Format("{0}-{1}", product.ProductId, badSkuCounter);
                        badSkuCounter++;
                    }

                    // make merchello product
                    Guid merchelloGuid = MProductService.MakeMerchelloProduct(product);

                    // make umbraco product content node
                    UProductService.MakeProduct(product, nodeId, merchelloGuid);

                    // update counter and limit to 3 if flag is set
                    if (test3Only)
                    {
                        prodCounter++;
                        if (prodCounter > 3)
                        {
                            break;
                        }
                    }
                }
            }
        }
 public static IList <UProduct> LoadForProductId(int catId)
 {
     return(UCategoryProductRepository.LoadAll(catId));
 }