public ActionResult Rendering() { var keyword = System.Web.HttpContext.Current.Request.QueryString["search"]; IEnumerable <Product> products = new List <Product>(); CategoryRenderingViewModel productsViewModel = new CategoryRenderingViewModel(); List <Guid> guids = new List <Guid>(); if (!string.IsNullOrEmpty(keyword)) { products = Product.Find(p => p.VariantSku == null && p.DisplayOnSite && ( p.Sku.Contains(keyword) || p.Name.Contains(keyword) || p.ProductDescriptions.Any(d => d.DisplayName.Contains(keyword) || d.ShortDescription.Contains(keyword) || d.LongDescription.Contains(keyword) ) ) ); } productsViewModel.ProductItemGuids = guids; foreach (var product in products.Where(x => x.DisplayOnSite)) { productsViewModel.ProductItemGuids.Add(product.Guid); } productsViewModel.ProductCardRendering = RenderingContext.Current.Rendering.DataSource; return(View(productsViewModel)); }
public ActionResult Rendering() { var categoryViewModel = new CategoryRenderingViewModel(); var currentCategory = _catalogContext.CurrentCategory; categoryViewModel.DisplayName = new HtmlString(FieldRenderer.Render(RenderingContext.Current.ContextItem, "Display name")); categoryViewModel.ProductItemGuids = GetProductGuidsInFacetsAndSelectedProductOnSitecoreItem(currentCategory); categoryViewModel.ProductCardRendering = RenderingContext.Current.Rendering.DataSource; return(View(categoryViewModel)); }