private void findCrossSell(int id) { if (ProductInfoCatalog != null) { var crossSellList = new List <CrossSellInfo>(); ProductDetail.CollectAllCrossSellProducts(CatalogHelper.FindCategory(ProductInfoCatalog, id), crossSellList); if (crossSellList.Count > 0) { CrossSellInfo candidate = null; foreach (CrossSellInfo c in crossSellList) { if (ProductDetail.ShouldSelectThisCrossSell(c.Product, ShoppingCart, Session[ProductDetail.LAST_SEEN_PRODUCT_SESSION_EKY] as CrossSellInfo, Session[ ProductDetail .LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] as CrossSellInfo)) { if (!ProductDetail.IfOutOfStock(c.Product, AllSKUS)) { candidate = c; break; } } } // if nothing found if (candidate == null) { candidate = ProductDetail.SelectCrossSellFromPreviousDisplayOrCrssSellList(ShoppingCart, crossSellList, Session[ ProductDetail .LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY ] as CrossSellInfo, AllSKUS); } if (candidate != null) { Session[ProductDetail.LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] = candidate; // fire event CrossSellFound(this, new CrossSellEventArgs(candidate)); return; } } } else { LoggerHelper.Error(string.Format("ProductInfoCatalog is null in finding cross-sell : {0}", this.Locale)); } NoCrossSellFound(this, null); }
public void findCrossSell(List <ShoppingCartItem_V01> products) { if (products.Count == 0) { NoCrossSellFound(this, null); return; } List <CrossSellInfo> crossSellList = new List <CrossSellInfo>(); foreach (ShoppingCartItem_V01 cartItem in products) { var item = ShoppingCart.ShoppingCartItems.Find(s => s.SKU == cartItem.SKU); if (item != null) { if (item.ProdInfo == null || item.ParentCat == null || item.ProdInfo.CrossSellProducts == null) { continue; } foreach (int cat in item.ProdInfo.CrossSellProducts.Keys) { crossSellList.AddRange(from a in item.ProdInfo.CrossSellProducts[cat] select new CrossSellInfo(cat, a)); } } } if (crossSellList.Count > 0) { CrossSellInfo candidate = null; foreach (CrossSellInfo c in crossSellList) { if (ProductDetail.ShouldSelectThisCrossSell(c.Product, ShoppingCart, Session[ProductDetail.LAST_SEEN_PRODUCT_SESSION_EKY] as CrossSellInfo, Session[ ProductDetail. LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] as CrossSellInfo)) { if (!ProductDetail.IfOutOfStock(c.Product, AllSKUS)) { candidate = c; break; } } } // if nothing found if (candidate == null) { candidate = ProductDetail.SelectCrossSellFromPreviousDisplayOrCrssSellList(ShoppingCart, crossSellList, Session[ ProductDetail. LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY ] as CrossSellInfo, AllSKUS); } if (candidate != null) { Session[ProductDetail.LAST_SEEN_CROSS_SELL_PRODUCT_SESSION_EKY] = candidate; // fire event CrossSellFound(this, new CrossSellEventArgs(candidate)); return; } } NoCrossSellFound(this, null); //findCrossSell(); }