To get inventoryItem.id, location.id and stock I run:
product(id: "gid://shopify/Product/' . $productId . '") {
variants(first: 10) {
edges {
node {
inventoryItem {
id
inventoryLevels(first: 10) {
" edges {
node {
id
location {
id
}
quantities(names: ["available"]) {
id
name
quantity
}
}
}
}
}
}
}
}
}
I use those values than to update stock:
$body = [
'query' => '
mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) {
inventoryAdjustQuantities(input: $input) {
userErrors {
field
message
}
inventoryAdjustmentGroup {
createdAt
reason
referenceDocumentUri
changes {
name
delta
}
}
}
}',
'variables' => [
'input' => [
'reason' => 'restock',
'name' => 'available',
'changes' => [
[
'delta' => $delta,
'inventoryItemId' => $inventoryItemId,
'locationId' => $locationId
]
]
]
]
];
How can I get:
“The specified inventory item could not be found.”
?
If I run the update on the same productId again, it works.