Coveo Hive - Custom Facet Sort Options
I have some facet values that start with numbers and are not sorting correctly since they are sorting as a strings (ex... 1 IN, 10 IN, 12 IN, 2 IN, 22 IN, 3 IN, 4 IN...). What are the options for customizing how facet values are sorted? I found the article below from 3 years ago. Is that still the way it's done? I'm using Coveo 5.
Coveo for Sitecore version: 18.104.22.168
Sitecore version: 22.214.171.124604
The solution you found is still valid with recent Coveo for Sitecore versions.
In Coveo for Sitecore v5 with Coveo for Sitecore Hive, the UI components are now MVC renderings. So the file names and items to duplicate would be different.
With Coveo for Sitecore Hive, the initialization happens only when the DOM is loaded. Another approach is to alter the data attributes values before initialization. See https://docs.coveo.com/en/2401/coveo-for-sitecore-v5/overriding-coveo-for-sitecore-hive-initialization-options
You must set a fixed `DOM Unique Id` value in your facet data source item. E.g.: `sizeFacet`.
Your script would be inserted on the page after the facet component and would look like this:
<script> var sizeFacet = document.getElementById("sizeFacet"); sizeFacet.dataset.customSort = "1 IN,2 IN,3 IN..."; </script>