Solved

Set Inventory Level API

nethra31308
Shopify Partner
4 1 0

Set the inventory level API requires to pass the system-generated Inventory Item ID & Location IDs rather than the generic unique ID's. Since the end systems don't store the System IDs, is there anyway to set the inventory level by passing the SKU code & location code.

Accepted Solution (1)

Colin_M
Shopify Partner
14 1 6

This is an accepted solution.

No, you should use a query to get all item ids, cache this locally and use it to map the SKUs to location ids. You can use `inventory_levels/connect` and `inventory_levels/disconnect` webhooks to invalidate your local cache.

 

GraphQL to get all item ids for a location (use a loop with cursor while hasNextPage):

 

query locationItemIds($locationId: ID!, $cursor: String) {
location(id: $locationId) {
inventoryLevels(first: 250, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
item {
legacyResourceId
sku
}
}
}
}
}
}

 

View solution in original post

Reply 1 (1)

Colin_M
Shopify Partner
14 1 6

This is an accepted solution.

No, you should use a query to get all item ids, cache this locally and use it to map the SKUs to location ids. You can use `inventory_levels/connect` and `inventory_levels/disconnect` webhooks to invalidate your local cache.

 

GraphQL to get all item ids for a location (use a loop with cursor while hasNextPage):

 

query locationItemIds($locationId: ID!, $cursor: String) {
location(id: $locationId) {
inventoryLevels(first: 250, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
item {
legacyResourceId
sku
}
}
}
}
}
}