We can update or sort the values of brand in alphabetic order, brand means a facet filter field
Obtain the view related to the shop by brand section, which is ‘FacetsFacetedNavigationItemView’, then obtained the display values from the view
created a json file to make the brand field ID configurable since we are using that field ID in the development
updated the context of the view, then sorted the display values when id equals “custitem1.”
getContext: _.wrap(FacetsFacetedNavigationItemView.prototype.getContext, function (fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
var facetDisplayId = context.facetId;
var brandFieldId = SC.CONFIGURATION.Brandssubtab.fieldid;
if (facetDisplayId === brandFieldId) {
var facetDisplayValues = context.displayValues;
if (!!facetDisplayValues) {
facetDisplayValues.sort(function (a, b) {
var displayNameA = a.displayName.toUpperCase(); // Convert to uppercase to ignore case
var displayNameB = b.displayName.toUpperCase();
if (displayNameA < displayNameB) {
return -1;
}
if (displayNameA > displayNameB) {
return 1;
}
return 0;
});
}
}
return context;
})
})