0

I'm working on Magento 2.4.2 with Elasticsearch 7.6. I've tried to add a sorting option on the category page which will sort the products on the basis of quantity added in the product.

I've checked multiple posts on StackOverflow and tried multiple things to achieve this but didn't get the expected results.

Elasticsearch\\Common\\Exceptions\\BadRequest400Exception(code: 400): {\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [availability.sort_availability] in order to sort on

Can anybody let me know how to sort products on the basis of quantity in Magento 2.4.

3
  • Sorting has been broken since the introduction of the ElasticSearch and removal of MySQL. It is still broken and there is no movement to fix it. I recommend buying this plugin: mirasvit.com/magento-2-improved-sorting.html It works well and you can add as many attributes as you want for sorting. Sep 14, 2021 at 7:36
  • If you really want to do this yourself, you would need to create an indexer for quantity that would run before Catalog Search runs. Quantity is not really an attribute, so you would need to create a new attribute, then index quantity into the new attribute and make the new attribute searchable within ElasticSearch. Its about 1-2 weeks of work. Sep 14, 2021 at 8:15
  • Thank you for your reply @KalvinKlien. Yes, it'll be a long customization to do.
    – Sumit
    Sep 14, 2021 at 9:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.