rahr1 wrote:
Hi
I noticed that when using the Search textbox if I enter the full SKU number and hit enter no results return even though there is a product with that number (I copied the SKU from the product). However if enter the SKU and wait until the app does a background search, the product is brought up as a hint. Any reason why this happens?
Using nopCommerce 3.20
Hi,
Yes, By default nopCommerce Search By SKU is not enabled.
It's just one line change.
You can edit CatalogController.cs file in Nop.Web\Controllers.
..\Presentation\Nop.Web\Controllers\CatalogController.cs
In CatalogController.cs file search for keyword 'serachSku:' and check that values.
If it 'searchSku: searchInDescriptions' changes it to 'searchSku: true'
compile code and check by searching item by sku.
"searchSku: searchInDescriptions"
Replace above line with
"searchSku: true"
After this change code will look like below. I've commented original line and added change in new line.
products = _productService.SearchProducts(
categoryIds: categoryIds,
manufacturerId: manufacturerId,
storeId: _storeContext.CurrentStore.Id,
visibleIndividuallyOnly: true,
priceMin: minPriceConverted,
priceMax: maxPriceConverted,
keywords:model.Q,
searchDescriptions: searchInDescriptions,
//Change to Enable Search By Sku in NopCommerce.
//searchSku: searchInDescriptions,
searchSku: true,
searchProductTags: searchInProductTags,
languageId:_workContext.WorkingLanguage.Id,
pageIndex: command.PageNumber - 1,
pageSize: command.PageSize);
model.Products = PrepareProductOverviewModels(products).ToList();
Please +1 vote if it help you.
This code is for nop 3.20.
Thanks.
Ajay Saksena