Closed bartdelvaux closed 6 years ago
Having no position and having the position 0 is a different semantic. In the first case it means product are not ordered and should be displayed after ordered products when default sort order is applied.
Additionally ElasticSuite, does not use Magento standard positioning but it's own (the one you see in the merchandising tool in category admin). No product can get the position 0 using this tool.
=> It works as designed and as expected
When I have a child category which is a deepest node in a category tree, the sorting on position is not sorting as I expect.
Preconditions
Magento Version : CE 2.2
ElasticSuite Version : 2.5.13
Environment : Production mode
Steps to reproduce
A product with a position of 0 looks like this:
In the deepest level, the position is not set.
Expected result
When sorting ascending (from low to high), I expect that the products with a missing position are ordered before the products with a (higher) position. This is also how sorting works in MySQL (null values are sorted first).
Actual result
This is only the case when you have a missing position in a category and you are sorting that category.
What could be wrong:
When I debug the ElasticSearch query, I see the following JSON for the category sorting:
I see the line
"missing": "_first"
in the JSON. When sortingdesc
(high to low), I expect that the missing values are sorted last.When sorting
asc
, I see in the JSON "missing": "_last". In that case, I expect that the missing values are sorted first.In the class
Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\SortOrder\Builder
, when I change on line 73_first
with_last
, the sorting works as I expect.