public virtual IActionResult RecentlyViewedProducts() { if (!_catalogSettings.RecentlyViewedProductsEnabled) { return(Content("")); } var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber); var model = new List <ProductOverviewModel>(); model.AddRange(_productWebService.PrepareProductOverviewModels(products)); return(View(model)); }
public IViewComponentResult Invoke(int?productThumbPictureSize, bool?preparePriceModel) { if (!_catalogSettings.RecentlyViewedProductsEnabled) { return(Content("")); } var preparePictureModel = productThumbPictureSize.HasValue; var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } //prepare model var model = new List <ProductOverviewModel>(); model.AddRange(_productWebService.PrepareProductOverviewModels(products, preparePriceModel.GetValueOrDefault(), preparePictureModel, productThumbPictureSize)); return(View(model)); }
public IViewComponentResult Invoke(int?productThumbPictureSize) { if (!_catalogSettings.SuggestedProductsEnabled || _catalogSettings.SuggestedProductsNumber == 0) { return(Content("")); } var products = _productService.GetSuggestedProducts(_workContext.CurrentCustomer.CustomerTags.ToArray()); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } //prepare model var model = _productWebService.PrepareProductOverviewModels(products.Take(_catalogSettings.SuggestedProductsNumber), true, true, productThumbPictureSize).ToList(); return(View(model)); }
public IViewComponentResult Invoke(string productId, int?productThumbPictureSize) { if (!_catalogSettings.ProductsAlsoPurchasedEnabled) { return(Content("")); } //load and cache report var productIds = _cacheManager.Get(string.Format(ModelCacheEventConsumer.PRODUCTS_ALSO_PURCHASED_IDS_KEY, productId, _storeContext.CurrentStore.Id), () => _orderReportService .GetAlsoPurchasedProductsIds(_storeContext.CurrentStore.Id, productId, _catalogSettings.ProductsAlsoPurchasedNumber) ); //load products var products = _productService.GetProductsByIds(productIds); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } //prepare model var model = _productWebService.PrepareProductOverviewModels(products, true, true, productThumbPictureSize).ToList(); return(View(model)); }
public IViewComponentResult Invoke(int?productThumbPictureSize) { if (!_catalogSettings.ShowBestsellersOnHomepage || _catalogSettings.NumberOfBestsellersOnHomepage == 0) { return(Content("")); } //load and cache report var report = _cacheManager.Get(string.Format(ModelCacheEventConsumer.HOMEPAGE_BESTSELLERS_IDS_KEY, _storeContext.CurrentStore.Id), () => _orderReportService.BestSellersReport( storeId: _storeContext.CurrentStore.Id, pageSize: _catalogSettings.NumberOfBestsellersOnHomepage) .ToList()); //load products var products = _productService.GetProductsByIds(report.Select(x => x.ProductId).ToArray()); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } //prepare model var model = _productWebService.PrepareProductOverviewModels(products, true, true, productThumbPictureSize).ToList(); return(View(model)); }
public IViewComponentResult Invoke(int?productThumbPictureSize) { var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList(); var products = _productService.GetCrosssellProductsByShoppingCart(cart, _shoppingCartSettings.CrossSellsNumber); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } var model = _productWebService.PrepareProductOverviewModels(products, productThumbPictureSize: productThumbPictureSize, forceRedirectionAfterAddingToCart: true) .ToList(); return(View(model)); }
//[ValidateInput(false)] public virtual IActionResult SearchTermAutoComplete(string term) { if (String.IsNullOrWhiteSpace(term) || term.Length < _catalogSettings.ProductSearchTermMinimumLength) { return(Content("")); } //products var productNumber = _catalogSettings.ProductSearchAutoCompleteNumberOfProducts > 0 ? _catalogSettings.ProductSearchAutoCompleteNumberOfProducts : 10; var products = _productService.SearchProducts( storeId: _storeContext.CurrentStore.Id, keywords: term, searchSku: false, languageId: _workContext.WorkingLanguage.Id, visibleIndividuallyOnly: true, pageSize: productNumber); var models = _productWebService.PrepareProductOverviewModels(products, false, _catalogSettings.ShowProductImagesInSearchAutoComplete, _mediaSettings.AutoCompleteSearchThumbPictureSize).ToList(); var result = (from p in models select new { label = p.Name, producturl = Url.RouteUrl("Product", new { SeName = p.SeName }), productpictureurl = p.DefaultPictureModel.ImageUrl }) .ToList(); //tbh var qqqq = new Newtonsoft.Json.JsonSerializerSettings(); return(Json(result));// . JsonRequestBehavior.AllowGet); }
public IViewComponentResult Invoke(string productId, int?productThumbPictureSize) { //load and cache report var productIds = _cacheManager.Get(string.Format(ModelCacheEventConsumer.PRODUCTS_RELATED_IDS_KEY, productId, _storeContext.CurrentStore.Id), () => _productService.GetProductById(productId).RelatedProducts.Select(x => x.ProductId2).ToArray() ); //load products var products = _productService.GetProductsByIds(productIds); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } var model = _productWebService.PrepareProductOverviewModels(products, true, true, productThumbPictureSize).ToList(); return(View(model)); }
public virtual IActionResult SearchTermAutoComplete(string term, string categoryId) { if (String.IsNullOrWhiteSpace(term) || term.Length < _catalogSettings.ProductSearchTermMinimumLength) { return(Content("")); } //products var productNumber = _catalogSettings.ProductSearchAutoCompleteNumberOfProducts > 0 ? _catalogSettings.ProductSearchAutoCompleteNumberOfProducts : 10; var categoryIds = new List <string>(); if (!string.IsNullOrEmpty(categoryId)) { categoryIds.Add(categoryId); if (_catalogSettings.ShowProductsFromSubcategoriesInSearchBox) { //include subcategories categoryIds.AddRange(_catalogWebService.GetChildCategoryIds(categoryId)); } } var products = _productService.SearchProducts( storeId: _storeContext.CurrentStore.Id, keywords: term, categoryIds: categoryIds, searchSku: _catalogSettings.SearchBySku, searchDescriptions: _catalogSettings.SearchByDescription, languageId: _workContext.WorkingLanguage.Id, visibleIndividuallyOnly: true, pageSize: productNumber); var models = _productWebService.PrepareProductOverviewModels(products, false, _catalogSettings.ShowProductImagesInSearchAutoComplete, _mediaSettings.AutoCompleteSearchThumbPictureSize).ToList(); var result = (from p in models select new { label = p.Name, producturl = Url.RouteUrl("Product", new { SeName = p.SeName }), productpictureurl = p.DefaultPictureModel.ImageUrl }) .ToList(); return(Json(result)); }
public IViewComponentResult Invoke(int?productThumbPictureSize) { var products = _productService.GetAllProductsDisplayedOnHomePage(); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) { return(Content("")); } var model = _productWebService.PrepareProductOverviewModels(products, true, true, productThumbPictureSize).ToList(); return(View(model)); }
public IViewComponentResult Invoke(int? productThumbPictureSize) { if (!_catalogSettings.RecommendedProductsEnabled) return Content(""); var products = _productService.GetRecommendedProducts(_workContext.CurrentCustomer.GetCustomerRoleIds()); //ACL and store mapping products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList(); //availability dates products = products.Where(p => p.IsAvailable()).ToList(); if (!products.Any()) return Content(""); //prepare model var model = _productWebService.PrepareProductOverviewModels(products, true, true, productThumbPictureSize).ToList(); return View(model); }