BUG: Incorrect result when WooCommerce settings Default product sorting set to Popularity #3617
Closed
Description
Describe the bug
When "Default product sorting" settings is set to "Popularity". The shop page doesn't return the popular products. The problem is that the order
in a query is set to asc
"sort": [
{
"meta.total_sales.double": {
"order": "asc"
}
},
{
"post_date": {
"order": "asc"
}
}
]
This issue caused by this change in this snippet https://github.com/10up/ElasticPress/blob/develop/includes/classes/Feature/WooCommerce/Products.php#L919 compare to what 4.6.0 has https://github.com/10up/ElasticPress/blob/4.6.0/includes/classes/Feature/WooCommerce/WooCommerce.php#L516
Steps to Reproduce
- Set the "Default product sorting" settings set to "Popularity"
- Go to shop page. The popular post wouldn't be listed
- Select any other sorting option.
- Again, select the Popularity and this time it will display the correct result.
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct