/// <summary> /// The collect all cross sell products. /// </summary> /// <param name="current"> /// The current. /// </param> /// <param name="itemList"> /// The item list. /// </param> public static void CollectAllCrossSellProducts( Category_V02 current, List <CrossSellInfo> itemList) { if (current != null) { if (current.SubCategories != null) { foreach (Category_V02 c in current.SubCategories) { CollectAllCrossSellProducts(c, itemList); } } if (current.Products != null) { foreach (ProductInfo_V02 d in current.Products) { if (d.CrossSellProducts == null) { continue; } foreach (int cat in d.CrossSellProducts.Keys) { itemList.AddRange(from a in d.CrossSellProducts[cat] select new CrossSellInfo(cat, a)); } } } } }
public void ShowCategory(int id, int rootID, int parentID) { if (ProductInfoCatalog != null) { Category_V02 category = CatalogHelper.FindCategory(ProductInfoCatalog, id, parentID, rootID); Category_V02 rootCategory = CatalogHelper.FindCategory(ProductInfoCatalog, rootID); if (category != null && rootCategory != null && CatalogProvider.IsDisplayable(rootCategory, Thread.CurrentThread.CurrentCulture.Name)) { CategoryName.Text = category.DisplayName; Overview.Text = category.Description; DivImage.Style["background"] = "url(" + category.ImagePath + ");background-repeat: no-repeat; background-position: center right"; SubCat.PopulateProducts(category, rootCategory); if (HLConfigManager.Configurations.DOConfiguration.AddScriptsForRecommendations) { // Send data to Adobe Target and Salesforce, only for main categories if (category.ID == rootCategory.ID) { AT_categoryName = string.Format("{0}_{1}", Locale, category.DisplayName); } } } else { if (!(id == 0 && rootID == 0 && parentID == 0)) { LoggerHelper.Warn(string.Format("No category found in ShowCategory for {0}-{2}-{3} {1}", id, this.Locale, rootID, parentID)); } } } }
/// <summary> /// The should take. /// </summary> /// <param name="category"> /// The category. /// </param> /// <param name="bEventTicket"> /// The b event ticket. /// </param> /// <returns> /// The should take. /// </returns> private bool shouldTake(Category_V02 category, bool bEventTicket) { if (category.Products != null) { foreach (ProductInfo_V02 prod in category.Products) { if (shouldTake(prod, bEventTicket)) { return(true); } } } if (category.SubCategories != null) { foreach (Category_V02 sub in category.SubCategories) { if (shouldTake(sub, bEventTicket)) { return(true); } } } return(false); }
private static List <CategoryProductModel> GetAllProducts(Category_V02 rooCategory, Category_V02 category, List <CategoryProductModel> allProducts) { if (category.SubCategories != null) { allProducts = category.SubCategories.Aggregate(allProducts, (current, sub) => GetAllProducts(rooCategory, sub, current)); } if (category.Products != null) { allProducts.AddRange(from p in category.Products where p.SKUs != null && p.SKUs.Count > 0 && (from s in p.SKUs where s.IsDisplayable select s).Any() select new CategoryProductModel { Category = category, Product = p, RootCategory = rooCategory, } ); } return(allProducts); }
public static List <ProductCategory> GetProducts(Category_V02 category) { var prodList = new List <ProductCategory>(); prodList = GetAllProducts(category, category, prodList); return(prodList); }
private IEnumerable <InvoiceLineModel> GetInvoiceLinesFromCategory(Category_V02 category, string locale, string countryCode, bool isCustomer) { var result = new List <InvoiceLineModel>(); //set & check the cache..... if (null != category.Products) { foreach (var productInfoV02 in category.Products) { if (null != productInfoV02.SKUs && productInfoV02.SKUs.Any()) { result.AddRange( productInfoV02.SKUs .Where(x => x != null && x.SKU != null) .Select(p => GetInvoiceLineFromSku(p.SKU, locale, countryCode, 1, isCustomer) )); } } } if (category.SubCategories != null && category.SubCategories.Any()) { foreach (var subcategory in category.SubCategories) { result.AddRange(GetInvoiceLinesFromCategory(subcategory, locale, countryCode, isCustomer)); } } return(result); }
/// <summary> /// The get all products. /// </summary> /// <param name="category"> /// The category. /// </param> /// <param name="allProducts"> /// The all products. /// </param> /// <returns> /// </returns> private List <UICategoryProduct> getAllProducts(Category_V02 rooCategory, Category_V02 category, List <UICategoryProduct> allProducts) { if (category.SubCategories != null) { foreach (Category_V02 sub in category.SubCategories) { allProducts = getAllProducts(rooCategory, sub, allProducts); } } if (category.Products != null) { allProducts.AddRange(from p in category.Products where p.SKUs != null && p.SKUs.Count > 0 && (from s in p.SKUs where s.IsDisplayable select s).Count() > 0 select new UICategoryProduct { Category = category, Product = p, RootCategory = rooCategory, } ); } return(allProducts); }
private static List <ProductCategory> GetAllProducts(Category_V02 rooCategory, Category_V02 category, List <ProductCategory> allProducts) { if (category.SubCategories != null) { foreach (Category_V02 sub in category.SubCategories) { allProducts = GetAllProducts(rooCategory, sub, allProducts); } } if (category.Products != null) { allProducts.AddRange(from p in category.Products where p.SKUs != null && p.SKUs.Count() > 0 && p.SKUs.Any(s => s.IsDisplayable) select new ProductCategory() { RootCategory = rooCategory, Category = category, Product = p }); } return(allProducts); }
/// <summary> /// The get bread crumb. /// </summary> /// <param name="currentCategory"> /// The current category. /// </param> /// <param name="rootCategory"> /// The root category. /// </param> /// <returns> /// The get bread crumb. /// </returns> public static string getBreadCrumbText(Category_V02 currentCategory, Category_V02 rootCategory, ProductInfo_V02 product) { if (currentCategory == null || rootCategory == null) { return(string.Empty); } try { Category_V02 category = rootCategory; List <Category_V02> listCategory = new List <Category_V02>(); while (category != null) { category = CatalogHelper.getCategory(currentCategory, category, ref listCategory); } if (rootCategory.SubCategories == null) { listCategory.Add(rootCategory); } return(CatalogHelper.getBreadCrumbText(currentCategory, rootCategory, listCategory) + product.DisplayName); } catch { LoggerHelper.Error(string.Format("Error getBreadCrumb catID : {0}", currentCategory.ID)); } return(string.Empty); }
private void navigateToProductDetailPage(string sku, string cmp) { Dictionary <string, SKU_V01> allSKUs = CatalogProvider.GetAllSKU(Locale, base.CurrentWarehouse); if (allSKUs != null) { SKU_V01 sku01; if (allSKUs.TryGetValue(sku, out sku01)) { if (sku01.Product != null) { Category_V02 category = findCategoryByProductID(ProductInfoCatalog.RootCategories, sku01.Product.ID); if (category != null) { if (cmp != null) { Response.Redirect( "~/ordering/ProductDetail.aspx?ProdInfoID=" + sku01.Product.ID + "&CategoryID=" + category.ID + "&CMP=" + cmp, false); } else { Response.Redirect( "~/ordering/ProductDetail.aspx?ProdInfoID=" + sku01.Product.ID + "&CategoryID=" + category.ID, false); } } } } } }
private Category_V02 findCategoryByProductID(List <Category_V02> categoryList, int prodID) { Category_V02 cat = null; foreach (Category_V02 category in categoryList) { if (category.SubCategories != null) { if (category.Products != null && category.Products.Exists(p => p.ID == prodID)) { return(category); } if ((cat = findCategoryByProductID(category.SubCategories, prodID)) != null) { return(cat); } } else { if (category.Products != null && category.Products.Exists(p => p.ID == prodID)) { return(category); } } } return(cat); }
private void resetPage() { Category_V02 current = findRootCategory(false, ProductInfoCatalog.RootCategories); if (current != null) { ShowCategory(current.ID, current.ID, 0); findCrossSell(current.ID); } (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageResource1.Title") as string); upCategoryInfo.Update(); }
/// <summary> /// The find category. /// </summary> /// <param name="productInfoCatalog"></param> /// <param name="categoryID"></param> /// <param name="ParentCategoryID"> The category id. </param> /// <returns> /// </returns> /// <param name="rootCategoryID"></param> public static Category_V02 FindCategory(ProductInfoCatalog_V01 productInfoCatalog, int categoryID, int ParentCategoryID, int rootCategoryID) { var varRootCategories = productInfoCatalog.RootCategories.Where(r => r.ID == rootCategoryID); if (varRootCategories.Count() > 0) { Category_V02 rootCategory = varRootCategories.First(); return(CatalogHelper.findCategory(categoryID, ParentCategoryID, rootCategory)); } return(null); }
/// <summary> /// get BreadCrumb Text /// </summary> /// <param name="currentCategory"></param> /// <param name="rootCat"></param> /// <param name="listCategory"></param> /// <returns></returns> static string getBreadCrumbText(Category_V02 currentCategory, Category_V02 rootCat, List <Category_V02> listCategory) { string breadCrumb = string.Empty; for (int idx = 0; idx < listCategory.Count; idx++) { breadCrumb = breadCrumb + listCategory[idx].DisplayName + " > "; } return(breadCrumb); }
public static Category_V02 GetRootCategory(ProductInfoCatalog_V01 productInfoCatalog, int categoryID) { foreach (Category_V02 cat in productInfoCatalog.RootCategories) { Category_V02 categoryToFind = findCategoryByID(categoryID, cat); if (categoryToFind != null) { return(cat); } } return(null); }
/// <summary> /// The get category text. /// </summary> /// <param name="category"> /// The category. /// </param> /// <returns> /// The get category text. /// </returns> private string getCategoryText(Category_V02 category) { string text = string.Empty; Category_V02 parent = category.ParentCategory; while (parent != null) { text = parent.DisplayName + " > "; parent = parent.ParentCategory; } return(text); }
private Category_V02ItemCollection GetAllCategories() { Category_V02ItemCollection collection = new Category_V02ItemCollection(); Category_V02 cat02 = new Category_V02(); cat02.Description = "TestingMock"; cat02.DisplayName = "sku1316"; cat02.ParentCategory = null; cat02.SubCategories = null; cat02.ImagePath = "testing.jpg"; cat02.Products = GetProductInfoV02Mock(); collection.Add(1316, cat02); return(collection); }
private static bool ShouldTake(Category_V02 category, bool bEventTicket) { if (category.Products == null) { return(category.SubCategories != null && category.SubCategories.Any(sub => ShouldTake(sub, bEventTicket))); } if (category.Products.Any(prod => ShouldTake(prod, bEventTicket))) { return(true); } return(category.SubCategories != null && category.SubCategories.Any(sub => ShouldTake(sub, bEventTicket))); }
/// <summary> /// The on page properties changing_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void OnPagePropertiesChanging_Click(object sender, PagePropertiesChangingEventArgs e) { var productsBase = Page as ProductsBase; if (string.IsNullOrEmpty(productsBase.Locale)) { return; } DataPager2.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); if (Request.QueryString["cid"] != null && Request.QueryString["root"] != null) { PagerCategoryID = int.Parse(Request.QueryString["cid"] ?? "0"); PagerRootCategoryID = int.Parse(Request.QueryString["root"] ?? "0"); } int parentcategoryID = int.Parse(Request.QueryString["parent"] ?? "0"); Category_V02 rootCategory = null; // when it is from product detail screen if (PagerCategoryID == 0) { int categoryId = 0; if (int.TryParse(Request.QueryString["CategoryID"], out categoryId)) { PagerCategoryID = categoryId; } else { PagerCategoryID = 0; } rootCategory = CatalogHelper.GetRootCategory(ProductInfoCatalog, PagerCategoryID); // Category_V02 currentCategory; } else if (PagerRootCategoryID != 0) { rootCategory = ProductInfoCatalog.RootCategories.Find(r => r.ID == PagerRootCategoryID); } if (PagerCategoryID != 0 && rootCategory != null) { Category_V02 currentCategory; if (ProductInfoCatalog.AllCategories.TryGetValue(PagerCategoryID, out currentCategory)) { PopulateProducts(currentCategory, rootCategory); } } }
public static bool ShouldTake(Category_V02 category, bool bEventTicket, bool showAllInventory, bool isHAP, string action = "", List <string> categoryList = null) { // === Exclude Categories if (categoryList != null) { if (action == "exclude" && categoryList.Contains(category.DisplayName)) { return(false); } } if (category.Products != null) { foreach (ProductInfo_V02 prod in category.Products) { if (ShouldTake(prod, bEventTicket, showAllInventory, isHAP)) { return(true); } } } else { // this is if (category.SubCategories == null) { return(false); } } if (category.SubCategories != null) { // === Include Only Categories if (categoryList != null) { if (action == "display" && !categoryList.Contains(category.DisplayName)) { return(false); } } foreach (Category_V02 sub in category.SubCategories) { if (ShouldTake(sub, bEventTicket, showAllInventory, isHAP)) { return(true); } } } return(false); }
/// <summary> /// The populate categories. /// </summary> /// <param name="category"> /// The category. /// </param> private void populateCategories(Category_V02 category) { var prodList = new List <UICategoryProduct>(); prodList = getAllProducts(category, category, prodList); if (prodList != null) { Subcategories.DataSource = prodList; Subcategories.DataBind(); refreshBreadcrumbs(); } else { LoggerHelper.Error(string.Format("No category found for {0}", CategoryDropdown.SelectedValue)); } }
/// <summary> /// The find cross sell. /// </summary> private void findCrossSell() { var cs = Session[ProductDetail.LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] as CrossSellInfo; if (cs != null) { Category_V02 category = CatalogHelper.FindCategory(ProductInfoCatalog, cs.CategoryID); if (category != null) { // fire event CrossSellFound(this, new CrossSellEventArgs(cs)); return; } } NoCrossSellFound(this, null); }
private Category_V02 findAndSetFirstRootCategory(bool isEventTicketMode) { Category_V02 current = null; int categoryID, rootCategoryID, parentCategoryID = 0; getIDS(out categoryID, out rootCategoryID, out parentCategoryID); if (categoryID == 0 && rootCategoryID == 0) { current = findRootCategory(isEventTicketMode, ProductInfoCatalog.RootCategories); if (current != null) { SubCat.PagerCategoryID = current.ID; SubCat.PagerRootCategoryID = current.ID; } } return(current); }
/// <summary> /// Gets all products. /// </summary> /// <param name="rootCategory">The root category.</param> /// <param name="category">The category.</param> /// <param name="allProducts">All products.</param> /// <returns>List of price list items.</returns> private List <PriceListItemView> InitializeProductListItems(Category_V02 rootCategory, Category_V02 category, List <PriceListItemView> allProducts) { if (category.SubCategories != null) { allProducts = category.SubCategories.Aggregate(allProducts, (current, sub) => InitializeProductListItems(rootCategory, sub, current)); } if (category.Products != null) { allProducts.AddRange(category.Products .Where( product => product.SKUs != null && product.SKUs.Count > 0 && product.SKUs.Any(sku => sku.IsDisplayable)) .SelectMany( product => product.SKUs .SelectMany(productSku => this.AllSKUS. Where(sku => productSku.IsDisplayable && productSku.SKU == sku.Key && sku.Value.CatalogItem.ProductType == ProductType.Product) .Select(sku => new PriceListItemView( sku.Value.CatalogItem.EarnBase, sku.Value.CatalogItem.ListPrice) { Sku = sku.Key, ProductName = FormatDescription(sku.Value.Product.DisplayName), ShortDescription = FormatDescription(sku.Value.Description), Description = FormatDescription(string.Concat(sku.Value.Product.DisplayName, " ", sku.Value.Description)), Category = category.ParentCategory != null ? category.ParentCategory.DisplayName : category.DisplayName, SubCategory = category.DisplayName, VolumePoints = sku.Value.CatalogItem.VolumePoints, EarnBase = getAmountString(sku.Value.CatalogItem.EarnBase), RetailPrice = getAmountString(sku.Value.CatalogItem.ListPrice), IsTaxExempt = sku.Value.CatalogItem.IsTaxExempt })))); } return(allProducts); }
private Category_V02 findRootCategory(bool eventTicketMode, List <Category_V02> rootCategories) { Category_V02 current = null; foreach (Category_V02 category in rootCategories) { // Validate category display by rule if (CatalogProvider.IsDisplayable(category, Locale)) { if (Menu.ShouldTake(category, eventTicketMode, SessionInfo.ShowAllInventory, SessionInfo.IsHAPMode)) { current = category; break; } } } return(current); }
public static Category_V02 findCategoryByID(int categoryID, Category_V02 thisCategory) { if (thisCategory.ID == categoryID) { return(thisCategory); } if (thisCategory.SubCategories != null) { foreach (Category_V02 c in thisCategory.SubCategories) { var catFound = findCategoryByID(categoryID, c); if (catFound != null) { return(catFound); } } } return(null); }
public static Category_V02 getCategory(Category_V02 currentCategory, Category_V02 parentCategory, ref List <Category_V02> listCategory) { if (parentCategory.SubCategories != null) { if (!listCategory.Any(l => l.ID == parentCategory.ID)) { listCategory.Add(parentCategory); } if (currentCategory.ID == parentCategory.ID) { return(null); } var varCategories = parentCategory.SubCategories.Where(s => s.ID == currentCategory.ID); if (varCategories.Count() > 0) { Category_V02 thisCategory = varCategories.First(); if (!listCategory.Any(l => l.ID == thisCategory.ID)) { listCategory.Add(thisCategory); } if (!listCategory.Any(l => l.ID == currentCategory.ID)) { listCategory.Add(currentCategory); } return(thisCategory); } else { foreach (Category_V02 c in parentCategory.SubCategories) { List <Category_V02> tmpListCategory = new List <Category_V02>(listCategory); Category_V02 category = getCategory(currentCategory, c, ref tmpListCategory); if (category != null && category == currentCategory) { listCategory = tmpListCategory; return(category); } } } } return(null); }
private List <string> getSkus(Category_V02 category) { List <string> Lkus = new List <string>(); if (category.Products != null) { var listin = category.Products; foreach (var productInfoV02 in category.Products) { Lkus.AddRange(productInfoV02.SKUs.Select(x => x.SKU)); } } if (category.SubCategories != null && category.SubCategories.Count() >= 1) { foreach (var subcat in category.SubCategories) { Lkus.AddRange(getSkus(subcat)); } } return(Lkus); }
/// <summary> /// The populate products. /// </summary> /// <param name="currentCategory"> /// The current category. /// </param> /// <param name="rootCategory"> /// The root category. /// </param> public void PopulateProducts(Category_V02 currentCategory, Category_V02 rootCategory) { if (currentCategory == null) { return; } uxSubTablaHeader.Text = getBreadCrumb(currentCategory, rootCategory); uxSubTablaFooter.Text = uxSubTablaHeader.Text; var itemList = new List <UIProductInfo>(); collectAllProducts(SessionInfo.ShowAllInventory, currentCategory, itemList); if (itemList != null) { Products.DataSource = itemList.OrderBy(item => item.SortOrder).ToList(); Products.DataBind(); upProductList.Update(); //checkProductAvailability(ProductsBase.SessionInfo.ShowAllInventory, itemList); } }
/// <summary> /// The get bread crumb. /// </summary> /// <param name="currentCategory"> /// The current category. /// </param> /// <param name="rootCategory"> /// The root category. /// </param> /// <returns> /// The get bread crumb. /// </returns> private string getBreadCrumb(Category_V02 currentCategory, Category_V02 rootCategory) { if (currentCategory == null || rootCategory == null) { return(string.Empty); } try { Category_V02 category = rootCategory; var listCategory = new List <Category_V02>(); while (category != null) { category = CatalogHelper.getCategory(currentCategory, category, ref listCategory); } return(createHyperLink(currentCategory, rootCategory, listCategory)); } catch { LoggerHelper.Error(string.Format("Error getBreadCrumb catID : {0}", currentCategory.ID)); } return(string.Empty); }