How To

SortBy Options

3min



The default SortBy functionality can be modified within Template JS by overriding the default Script block. Additional supported options can be added as well as edits to the default labeling.

See : Custom Overrides for details on preparing for Klevu JS overriding

See : An in-action example and the source code on the Klevu CodeSandbox

Indexing

Supported options for product sorting must be supplied at the product level

  • price / sale_price
  • title
  • rating
  • id / date* (for newness)

*Please see this support article for important information about sorting by newness.



API Reference

Parameter

Description

RELEVANCE

Default combination of Klevu A.I. and merchandising configuration

PRICE_ASC, PRICE_DESC

Sort the results by the salePrice value of each record

NAME_ASC, NAME_DESC

Sort the results by the name of each record, in alphabetical order

RATING_ASC, RATING_DESC

Sort the results by each record's average rating, if this data has been indexed in your store

NEW_ARRIVAL_ASC, NEW_ARRIVAL_DESC

Sort your records based on their published date.

See : Klevu API Documentation for available Sorting Options



Template JS Override

The SortBy options template block can be modified using the Set Template override. The Set Custom Helpers are used to modify the desired display text of the selected option as well.

JavaScript