Loading...
Loading...
Reorder products in a manual Shopify collection by inventory level, moving in-stock products to the top and out-of-stock to the bottom.
npx skill4agent add 40rty-ai/shopify-admin-skills shopify-admin-collection-reorganizationtotalInventorycollectionReorderProductsshopify auth login --store <domain>read_productswrite_products| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| store | string | yes | — | Store domain (e.g., mystore.myshopify.com) |
| format | string | no | human | Output format: |
| dry_run | bool | no | false | Preview operations without executing mutations |
| collection_id | string | yes | — | GID of the manual collection (e.g., |
| sort_by | string | no | inventory_desc | |
⚠️ Step 2 executeswhich changes the product display order immediately. The sort is reversible — run again with the oppositecollectionReorderProductsto restore previous order — but the original custom order cannot be recovered once overwritten. Thesort_byarray passed to the mutation must be complete; partial moves produce undefined ordering. Always run withmovesfirst to review the computed sort order before committing.dry_run: true
collectionReorderProductssortOrderMANUALcollectionid: <collection_id>first: 250sortOrdertotalInventorysortOrder == "MANUAL"collectionReorderProductsid: <collection_id>movestotalInventorysort_by{id: <product_id>, newPosition: "<index>"}job.idjob.doneuserErrors# collection:query — validated against api_version 2025-01
query CollectionProducts($id: ID!, $first: Int!, $after: String) {
collection(id: $id) {
id
title
sortOrder
products(first: $first, after: $after) {
edges {
node {
id
title
totalInventory
variants(first: 100) {
edges {
node {
inventoryQuantity
}
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}# collectionReorderProducts:mutation — validated against api_version 2025-01
mutation CollectionReorderProducts($id: ID!, $moves: [MoveInput!]!) {
collectionReorderProducts(id: $id, moves: $moves) {
job {
id
done
}
userErrors {
field
message
}
}
}╔══════════════════════════════════════════════╗
║ SKILL: collection-reorganization ║
║ Store: <store domain> ║
║ Started: <YYYY-MM-DD HH:MM UTC> ║
╚══════════════════════════════════════════════╝[N/TOTAL] <QUERY|MUTATION> <OperationName>
→ Params: <brief summary of key inputs>
→ Result: <count or outcome>dry_run: true[DRY RUN]format: human══════════════════════════════════════════════
OUTCOME SUMMARY
Collection: <title>
Products reordered: <n>
Sort order: <inventory_desc|inventory_asc>
Errors: 0
Output: none
══════════════════════════════════════════════format: json{
"skill": "collection-reorganization",
"store": "<domain>",
"started_at": "<ISO8601>",
"completed_at": "<ISO8601>",
"dry_run": false,
"steps": [
{ "step": 1, "operation": "CollectionProducts", "type": "query", "params_summary": "collection_id: <gid>, first: 250", "result_summary": "<n> products fetched", "skipped": false },
{ "step": 2, "operation": "CollectionReorderProducts", "type": "mutation", "params_summary": "sort_by: inventory_desc, <n> moves", "result_summary": "job submitted", "skipped": false }
],
"outcome": {
"collection_title": "<title>",
"products_reordered": 0,
"sort_by": "inventory_desc",
"errors": 0,
"output_file": null
}
}dry_run: true| Error | Cause | Recovery |
|---|---|---|
| Collection is a smart/automated collection | Switch collection to manual ordering in Shopify admin |
| Invalid product ID or position | Check all product IDs belong to the collection |
| Collection not found | Invalid collection GID | Verify the GID in Shopify admin |
| Rate limit (429) | Too many paginated requests | Reduce |
dry_run: truecollectionReorderProductsjob.donefalsesort_by: inventory_asctotalInventorylow-inventory-restock