public ActionResult RecentlyViewedProducts(CatalogSearchQuery query)
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled || _catalogSettings.RecentlyViewedProductsNumber <= 0)
            {
                return(View(ProductSummaryModel.Empty));
            }

            var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(_catalogSettings.RecentlyViewedProductsNumber);
            var settings = _helper.GetBestFitProductSummaryMappingSettings(ProductSummaryViewMode.List);
            var model    = _helper.MapProductSummaryModel(products, settings);

            return(View(model));
        }
Exemplo n.º 2
0
        public virtual ActionResult RecentlyViewedProducts()
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(_catalogSettings.RecentlyViewedProductsNumber);

            var model = new List <ProductOverviewModel>();

            model.AddRange(_productModelFactory.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));
        }
Exemplo n.º 4
0
        public IViewComponentResult Invoke(int?productThumbPictureSize)
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var preparePictureModel = productThumbPictureSize.HasValue;
            var products            = _recentlyViewedProductsService.GetRecentlyViewedProducts(_catalogSettings.RecentlyViewedProductsNumber);

            //ACL and store mapping
            products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList();

            if (!products.Any())
            {
                return(Content(""));
            }

            //prepare model
            var model = new List <ProductOverviewModel>();

            model.AddRange(_productModelFactory.PrepareProductOverviewModels(products,
                                                                             preparePictureModel,
                                                                             productThumbPictureSize));

            return(View(model));
        }
        public IViewComponentResult Invoke(int?productThumbPictureSize, bool?preparePriceModel = true)
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var preparePictureModel = productThumbPictureSize.HasValue;
            var products            = _recentlyViewedProductsService.GetRecentlyViewedProducts(_catalogSettings.RecentlyViewedProductsNumber);

            //ACL and store mapping
            products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p));
            //availability dates
            products = products.Where(p => _productService.ProductIsAvailable(p));

            if (!products.Any())
            {
                return(Content(""));
            }

            //prepare model
            var model = _productModelFactory.PrepareProductOverviewModels(products,
                                                                          preparePriceModel.GetValueOrDefault(),
                                                                          true,
                                                                          productThumbPictureSize);

            return(View(model));
        }
Exemplo n.º 6
0
        //[ChildActionOnly]
        public virtual async Task <IViewComponentResult> RecentlyViewedProductsBlock(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(""));
            }

            //2017_07_14 18:52
            //boulder
            //you can start here

            //prepare model
            var model = new List <ProductOverviewModel>();

            model.AddRange(_productWebService.PrepareProductOverviewModels(products,
                                                                           preparePriceModel.GetValueOrDefault(),
                                                                           preparePictureModel,
                                                                           productThumbPictureSize));

            throw new NotImplementedException("add correct return view");
        }
Exemplo n.º 7
0
        public async Task <IViewComponentResult> InvokeAsync(int?productThumbPictureSize, bool?preparePriceModel)
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var preparePictureModel = productThumbPictureSize.HasValue;
            var products            = await _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber);

            if (!products.Any())
            {
                return(Content(""));
            }

            var model = await _mediator.Send(new GetProductOverview()
            {
                PreparePictureModel            = preparePictureModel,
                PreparePriceModel              = preparePriceModel.GetValueOrDefault(),
                PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
                ProductThumbPictureSize        = productThumbPictureSize,
                Products = products
            });

            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult RecentlyViewedProducts()
        {
            var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(9);

            if (!products.Any())
            {
                return(Content(""));
            }
            var models = products.PrepareProductBoxModels();

            return(PartialView("_RecentlyViewedProducts", models));
        }
Exemplo n.º 9
0
        public virtual IActionResult RecentlyViewedProducts()
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var products = _recentlyViewedProductsService.GetRecentlyViewedProducts(_catalogSettings.DefaultCategoryPageSize);

            var model = _productModelFactory.PrepareProductOverviewModels(products);

            return(View(model));
        }
Exemplo n.º 10
0
        public virtual async Task <IActionResult> RecentlyViewedProducts()
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var products = await _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber);

            var model = new List <ProductOverviewModel>();

            model.AddRange(await _productViewModelService.PrepareProductOverviewModels(products));

            return(View(model));
        }
Exemplo n.º 11
0
        public virtual async Task <IActionResult> RecentlyViewedProducts()
        {
            if (!_catalogSettings.RecentlyViewedProductsEnabled)
            {
                return(Content(""));
            }

            var products = await _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber);

            //prepare model
            var model = await _mediator.Send(new GetProductOverview()
            {
                Products = products,
            });

            return(View(model));
        }
Exemplo n.º 12
0
        public ActionResult RecentlyViewedItems(int count)
        {
            //get recently viewed
            IList <Product>            products = _recentlyViewedProductsService.GetRecentlyViewedProducts(count);
            IEnumerable <ProductModel> model    = new List <ProductModel>();

            if (products.Count() > 0)
            {
                model = from i in products
                        where i.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id, false) != null
                        select new ProductModel()
                {
                    Id                  = i.Id,
                    Name                = i.Name,
                    MetaTitle           = i.MetaTitle,
                    PictureThumbnailUrl = _pictureService.GetPictureUrl(i.ProductPictures.OrderBy(p => p.DisplayOrder).FirstOrDefault() != null ? i.ProductPictures.OrderBy(p => p.DisplayOrder).FirstOrDefault().PictureId : 0, showDefaultPicture: false, targetSize: 100),
                    ShortDescription    = i.GetLocalized(p => p.ShortDescription, _workContext.WorkingLanguage.Id, false),
                };
            }

            return(View(model));
        }