↕️ Sorting Products
The getCollection() function supports sorting with Shopify’s sortKey values and an optional reverse flag.
This lets you control the order of returned products — by price, title, popularity, and more.
🧠 Usage
const result = await getCollection({
sortKey: "PRICE",
reverse: true,
limit: 12,
});
🧮 Available Sort Keys
type ProductSortKey =
| "TITLE"
| "PRICE"
| "BEST_SELLING"
| "CREATED"
| "ID"
| "MANUAL"
| "RELEVANCE";
| Sort Key | Description |
|---|---|
TITLE | Alphabetical (A → Z) |
PRICE | Based on first variant’s price |
BEST_SELLING | Based on Shopify's sales data |
CREATED | Newest products first |
ID | Internal Shopify ID |
MANUAL | Custom sort order (only works in collections with manual sorting) |
RELEVANCE | Default when using search |
🔁 Reversing Sort Direction
You can use the reverse option to flip the sort direction:
reverse: true; // descending
reverse: false; // ascending (default)
PRICE+reverse: true→ highest to lowestTITLE+reverse: false→ A → Z
⚠️ Notes
- Not all sort keys are supported in all contexts.
MANUALonly works within collections that have manual ordering enabled. For more details, refer to the Shopify documentation on collection layout.RELEVANCEis best used with search-based queries.
✅ Next: Types Reference →
Description
Sort your Shopify product results by price, title, date, and more.