Sorts products in a category based on how it is sorted in backoffice

I am using Lucene search. I have a search query. It searches the products in a category. I need the search to return the products in the same order it is ordered inside the category

For sort by i used category_sort_order

But the result i got is not in the same order as in back office

This is the part of frontend result

This is the backoffice product

Litium version: [7.6.1]



as the sort order.

I made the changes for sortby. Still getting the same result. Am i doing something wrong with the code

It works fine when testing with similar code (see below). If you debug, is the sorting being applied correctly? Does it make a difference if you rebuild the index?

var searchQuery = new SearchQuery();
var products = new List<Litium.Web.Models.Products.ProductModel>();
searchQuery.CategorySystemId = Guid.Parse("76930397-9a9e-4b14-8b7a-5520ccb4a1b7");
searchQuery.SortBy = SearchQueryConstants.Recommended;
searchQuery.PageNumber = 1;
searchQuery.PageSize = 100000;
var response = _productSearchService.Search(searchQuery, searchQuery.Tags, true, true, true);

if (response.Hits != null)
		.Transform(searchQuery, response)
		.Select(x => x.Item));

var articles = products.Select(x => x.SelectedVariant.Id);



which matches

Please, check the log-file (not Event log in back office) to see the real queries where also the sort information is included. The sort for products in a category should have a sort field like category-{categorySystemId}-sortindex, if that not is the first selection in the sort fields the sorting on the query is not applied correctly.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.