We need to sort ordering on option values. for example Color is attribute and values are Red, Green, Blue then when we sort it should sort by alphabetically. So Blue, Green, Red results should come.
I hope you understand the problem. Default magento sort gives results based on option id not alphabetically.
Ref Issue:https://github.com/Smile-SA/elasticsuite/issues/450
1 Answer 1
EDIT; I think I misread.
If you wish to sort a product collection by an attribute then add this to the collection:
addAttributeToSort('attribute_code', 'desc')
If you're meaning that you wish for the options to be sorted alphabetically on the front end then you need to re-order them in the admin panel.
So click on stores in the sidebar and select 'product' under the attributes bit, select your 'colour' attribute and re-order them manually.
-
github.com/Smile-SA/elasticsuite/issues/450Navin Bhudiya– Navin Bhudiya2019年01月23日 08:24:09 +00:00Commented Jan 23, 2019 at 8:24
-
Ahh, I see - so the issue is outstanding and you wish to have a fix? I think might be a good idea to add to your main post.BAF– BAF2019年01月23日 08:27:41 +00:00Commented Jan 23, 2019 at 8:27
-
main post mens?Navin Bhudiya– Navin Bhudiya2019年01月23日 08:29:36 +00:00Commented Jan 23, 2019 at 8:29
-
sorry your original post - I can see you've added it now :)BAF– BAF2019年01月23日 08:31:30 +00:00Commented Jan 23, 2019 at 8:31
-
@BAF, Will this sort the products with option values? How can i sort as like below only load Red on top and rest followed by itJafar Pinjar– Jafar Pinjar2019年11月27日 06:01:46 +00:00Commented Nov 27, 2019 at 6:01