Elastic Path Commerce Development

Sorting Attributes

Sorting Attributes

Sorting is arranging offers in a navigation and search results in ascending or descending order. With sorting feature enabled, shoppers can sort offers based on product attributes. For example, a shopper wants to buy a T-shirt with the lowest price. The shopper searches for a T-shirt and gets all related results. The shopper can use the sorting feature to select the Price: Low to High sortable attribute and refine the search results further.

Elastic Path Commerce Manager provides options to configure, edit, or remove sortable attributes for a store. When you configure a store, Elastic Path Commerce Manager does not configure sorting attributes by default. You must configure the attributes in Elastic Path Commerce Manager to display the available options in the storefront on search and category pages, so shoppers can use the sort menu to refine storefront results. Business users and merchandisers can add and configure other sortable attributes based on the business needs, or use one of the following attributes:

  • Product name
  • Price
  • Featured
  • Relevance
  • Sales Count

The following image is an example of the sortable attributes available for shoppers:

The sorting feature uses sortattributes which is a part of offer-search-result and is retrieved during the call to Cortex. sortattributes sorts the results based on how the sort attributes are configured in Elastic Path Commerce Manager. Sortable attributes are added to the TSORTATTRIBUTEand TSORTLOCALIZEDNAME database tables for sortattributes to return the sortable attributes in the storefront. For more information about configuring sortable attributes, see the Store Configuration > Sorting section in the Elastic Path Commerce Manager guide. You can also import the attributes using the Import-Export Tool. For more information about the Import-Export Tool, see the Import-Export Tool Guide.

Example: Sorting Results in Cortex

The following example shows the search or navigation Cortex API results when you sort with sortattributes:

{
  "self": {
    "type": "offersearches.sort-attribute-selector-choice",
    "uri": "/offersearches/mobee/offers/qougwzlzo5xxezdtuvww65tjmwuxaylhmuwxg2l2mwqtljdtn5zhjwjegu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/filters/qgqka=/1/sort-attribute-selector/choice/gu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=",
    "href": "http://bammbamm-1-facetedsearch.elasticpath.net:8080/cortex/offersearches/mobee/offers/qougwzlzo5xxezdtuvww65tjmwuxaylhmuwxg2l2mwqtljdtn5zhjwjegu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/filters/qgqka=/1/sort-attribute-selector/choice/gu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm="
  },
  "messages": [],
  "links": [
    {
      "rel": "description",
      "type": "offersearches.sort-attribute",
      "href": "http://bammbamm-1-facetedsearch.elasticpath.net:8080/cortex/offersearches/mobee/offers/qougwzlzo5xxezdtuvww65tjmwuxaylhmuwxg2l2mwqtljdtn5zhjwjegu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/filters/qgqka=/1/sort-attribute-selector/choice/gu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/sortattribute"
    },
    {
      "rel": "selectaction",
      "type": "offersearches.sort-attribute-selector-choice",
      "href": "http://bammbamm-1-facetedsearch.elasticpath.net:8080/cortex/offersearches/mobee/offers/qougwzlzo5xxezdtuvww65tjmwuxaylhmuwxg2l2mwqtljdtn5zhjwjegu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/filters/qgqka=/1/sort-attribute-selector/choice/gu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm="
    },
    {
      "rel": "selector",
      "type": "offersearches.sort-attribute-selector",
      "href": "http://bammbamm-1-facetedsearch.elasticpath.net:8080/cortex/offersearches/mobee/offers/qougwzlzo5xxezdtuvww65tjmwuxaylhmuwxg2l2mwqtljdtn5zhjwjegu2dmmtdmfswmljtmi3tgljug5rdaljygrqtkljwgfrtgzdfmy4tkztbgm=/filters/qgqka=/1/sort-attribute-selector"
    }
  ]
}