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: { quantity: 1, 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.

See also