Skip to content

BUG: Incorrect result when WooCommerce settings Default product sorting set to Popularity #3617

Closed
@burhandodhy

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

  1. Set the "Default product sorting" settings set to "Popularity"
  2. Go to shop page. The popular post wouldn't be listed
  3. Select any other sorting option.
  4. 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

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions