sorting product with more than one key

When using the Storefront API (ver 2024-07), is it possible to sort products within a collection based on multiple sortKeys, such as PRICE and CREATED?

1 Like

Hi,there

I guess this is not directly supported. The API allows sorting by a single sortKey at a time.

For collections, you can use the sortKey parameter with values from the ProductCollectionSortKeys enum, which includes options like PRICE and CREATED, but not a combination of both.Then do another sorting in your logic by program

Hi, thank you for your reply. I was curious about how pagination works when we implement custom sorting in our program. How do we handle the cursor for the next page or previous page?

1 Like

You could refer to this https://shopify.dev/docs/api/usage/pagination-graphql