Skip to main content

Sort product results

Control the ordering of product search results.

Query​

query SortProducts($sortField: ProductSortField!, $sortOrder: SortOrder!) {
products(input: {
sortInputs: [
{ field: $sortField, order: $sortOrder }
]
}) {
itemsFound
items {
... on Product {
productId
names { language value }
price(input: { taxZone: "NL" }) { gross }
}
}
}
}

Variables​

{
"sortField": "PRICE",
"sortOrder": "ASC"
}

Response​

{
"data": {
"products": {
"itemsFound": 467,
"items": [
{
"productId": 3201,
"names": [{ "language": "NL", "value": "Kabelbinder 200mm" }],
"price": { "gross": 0.45 }
},
{
"productId": 1895,
"names": [{ "language": "NL", "value": "HP ProBook 450 G10 i5" }],
"price": { "gross": 899 }
}
]
}
}
}

How it works​

Available sort fields: SKU, SUPPLIER_CODE, CREATED_AT, LAST_MODIFIED_AT, NAME, SHORT_NAME, PRICE, RELEVANCE, CATEGORY_ORDER, PRIORITY. When using term for a text search, RELEVANCE ranks by match quality. You can pass multiple sort inputs for tie-breaking. Products that are equal on every sort input are ordered by priority (highest first) and then by creation date (oldest first), so their order stays the same from page to page. With CATEGORY_ORDER, products that are only in a subcategory follow the products ordered in the category. A price sort ranks a cluster by the price of its default product.

See also​