App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
How can i filter products based on quantity(low stock products < 10 not sold out) using admin graphql also i want total products with quantity less than 10.
Solved! Go to the solution
This is an accepted solution.
Hey! @Swiftbee,
To filter products with inventory quantity less than 10 and not sold out using Shopify Admin GraphQL API, you need to query productVariants and filter based on inventoryQuantity. Here's an example:
{
productVariants(first: 100, query: "inventory_quantity:<10 AND inventory_quantity:>0") {
edges {
node {
id
title
inventoryQuantity
product {
title
id
}
}
}
}
}
This query fetches variants with quantity between 1 and 9. To get the total count, you can use productVariants with query: and access pageInfo or keep paginating while counting manually, as GraphQL doesn't return total count directly.
This is an accepted solution.
Hey! @Swiftbee,
To filter products with inventory quantity less than 10 and not sold out using Shopify Admin GraphQL API, you need to query productVariants and filter based on inventoryQuantity. Here's an example:
{
productVariants(first: 100, query: "inventory_quantity:<10 AND inventory_quantity:>0") {
edges {
node {
id
title
inventoryQuantity
product {
title
id
}
}
}
}
}
This query fetches variants with quantity between 1 and 9. To get the total count, you can use productVariants with query: and access pageInfo or keep paginating while counting manually, as GraphQL doesn't return total count directly.