Magento – Magento 2 custom sort option with elastic search

elasticsearchmagento2.3

I have to implement below custom sort options

– Order: A to Z
– Order: Z to A
– Price: Low to High
– Price: High to Low

I have tried with the example given in link.
This is not working with elastic search. I am getting a message

We can't find products matching the selection.

Please help me if anyone has implemented this.

Best Answer

Custom Sort with ElasticSearch in Magento issue can be fixed by following these simple steps:

  • Navigate to Stores->Attributes->Product in Admin.
  • Add New Attribute.
  • In Properties->Attribute Properties:
    • Add Default Label (Eg: Price: Low to High)
    • Select the Catalog Input Type for Store Owner (Eg: Price) (In other cases Text Field is enough).
  • In Properties->Advanced Attribute Properties:
    • Add Attribute Code (Eg: price_asc).
  • In Storefront Properties->Storefront Properties:
    • Select User for Sorting in Product Listing to Yes

Once done with the above steps run the following commands,

bin/magento indexer:reindex catalogsearch_fulltext

bin/magento indexer:reindex
Related Topic