Sort

Standard Sorting

You can sort the results in your front office using standard sorting options, such as:

  • Creation date
  • Price
  • Name

To do this, the query accepts the sorting field and direction (ascending or descending, i.e., ASC/DESC).

Sorting can be combined with filters or navigation categories.

Below are examples of different standard sorting queries:

Creation Date (Ascending)

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=CREATION_DATE|ASC

Price (Descending)

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=price|DESC

Name (Ascending)

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=name|ASC

Custom Sorting

Our tool also allows you to customize sorting using attributes or custom fields.

📘

Note:

If multiple products or variants have the same value for an attribute or custom field, the display order may be unstable.

If a product does not have a value for the specified attribute or custom field, it will be placed at the end (on the last page).

Attributes and custom fields are configured in the back office.
Users can define whether an attribute or custom field is sortable.

Attributes and custom fields can be configured to be either indexed only or both indexed and sortable.
If an attribute or custom field is not explicitly configured, it will still be sortable as long as it is indexed.

Attribute Sorting

You can use an attribute to sort search results.

Format
sort=attr.{attributeName}|(ASC or DESC)

Example: Sorting by the "color" attribute.

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=attr.color|ASC

This will sort the results based on the product colors.

Custom Field Sorting

You can also use a custom field to sort search results.

Format
sort=cf.{customFieldName}|(ASC or DESC)

Example: Sorting by the custom field "promo."

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=cf.promo|ASC

This will sort the results based on the value of the "promo" custom field.

Multiple Sorting

You can combine two sorting criteria to refine your search results. This works with all types of sorting mentioned above.

Format
sort=cf.{customFieldName}|(ASC or DESC)&sort=attr.{attributeName}|(ASC or DESC)

Example: Sorting results first by the custom field "promo" and then by name.

GET /v2/shop/search?locale=xx-XX&cy=XXX&sort=cf.promo|ASC&sort=name|ASC\`

This query will first sort products by the "promo" custom field, and within those results, sort by product name.