_productService.SearchProducts move visibleIndividuallyOnly property to nopCommerce configuration

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
For some shops I need to be able to turn on advanced search so user can search inside subProducts (VisibleIndividually=False).

Currently it's hardcoded in Catalog Controller so it always ignores SubProducts.

My suggestion is to move it to config as follow:


CatalogController


  [ValidateInput(false)]
        public virtual ActionResult 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(
          var products = _productService.SearchProducts(
                storeId: _storeContext.CurrentStore.Id,
                keywords: term,
                languageId: _workContext.WorkingLanguage.Id,

                visibleIndividuallyOnly: _catalogSettings.SearchInVisibleIndividuallyOnly,

                pageSize: productNumber);

            var models =  _productModelFactory.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, JsonRequestBehavior.AllowGet);
        }
6 years ago
Hi Tomasz,

Thanks a lot for suggestion. We'll about it - https://github.com/nopSolutions/nopCommerce/issues/2530
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.