Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Quote:Is there any way that we could modify the search priority on AC 9.0.4 You can try something like this: Open Website/Controllers/ProductController.cs, locate the following line of code Code:var products = _productRepo.AdvancedSearch(keywords, categoryId, manufacturerId, true, true, true, 0, 0, false, shopByChoies, sortExpression, pageSize, index);
Inside the Search action method i.e. Code:public ActionResult Search(SearchResultsWidgetParams parameters, int categoryId = 0, int manufacturerId = 0, string keywords = "", string shopBy = "", int page = 1, int pageSize = 0, string sortExpression = "IsFeatured DESC, OrderBy ASC, Name ASC")
and replace with Code:
var products = _productRepo.AdvancedSearch(keywords, categoryId, manufacturerId, true, true, true, 0, 0, false, shopByChoies, sortExpression, pageSize, index);
// Sort results by matching keyword in Product Name
if (Request.QueryString.Count == 1 && products.Any(p => p.Name.ToLowerInvariant().Contains(keywords.ToLowerInvariant())))
{
products = products.OrderByDescending(p => p.Name.ToLowerInvariant().Contains(keywords.ToLowerInvariant())).ToList();
}
Compile the website and deploy the updated AbleCommerce.dll. Hope this helps! Edited by user Monday, August 30, 2021 8:25:38 AM(UTC)
| Reason: Not specified
|