Use Explicit Sorting
Consider creating a custom sort for a specific page or section of a page.
For example, if you have a custom table or grid and you want to enable sorting on any column of the grid, you might want to simply call the Search pipelet to sort the items. If this is the case, you can create a custom pipeline to do the sorting and configure the default sorting configuration to let you use explicit sortings.
To use explicit sorting:
- Select Unlike other sorting attributes, which are automatically indexed, but are separate from searchable attributes, sorting attributes passed by pipelines for explicit sorting are not automatically indexed. For this reason, you must make sure any attribute used to sort by in your explicit sorting is included in the searchable attributes for your storefront.Note: Because sorting and searchable attributes don't use the same data types, the attributes used for explicit sorting are restricted to the ones common to searchable attributes and sorting attributes. This means, for example, that you can't sort by Date +Time. You can't use dynamic attributes in explicit sorting.
- Check the attribute in the Product Index Attributes list if you want to sort products, or the Content Index Attributes list if you want to sort content items. If the attribute isn't in either list, click New to add it to the appropriate list.
- In , find the name of the default sorting rule for the storefront catalog and for the category that includes the page where you want to perform the explicit sorting.
- In
Explicit Sortings (sorting.explicit-sortings)
attribute. This can be the last attribute used for the sorting rule, so that it's only used if no other sorting rule applies.CAUTION:The Explicit Sortings attribute must be included in the sorting rule
select each of these rules and make
sure that they include the - To sort a search result by a defined sorting attribute, you must pass the attribute ID of the sorting attribute into the Search pipelet. This is a developer task.
You can specify that results are returned using a specific sorting rule, using the urlSort method for the SearchModel, ContentSearchModel or ProductSearchModel class, depending on the type of search. You can also specify that results are returned without a sorting option, using the urlDefaultSort method. If you specify a specific sorting rule, such as Price or Product name (A-Z), this takes priority and no further sorting rules are applied.