Bulk Operations - Fetch InventoryLevels for all stores?

Solved
Conner
Explorer
49 1 9

Hi All,

Is it possible to create a Bulk Operation with inventory levels for all stores? Currently, I've only been able to get it working for one specific store at a time.

Here's my mutation:

mutation {
  bulkOperationRunQuery (
    query: """
    {
      inventoryItems {
        edges {
          node {
            id
            inventoryLevel (locationId: "gid://shopify/Location/{LOCATION_ID}") {
              available
              id
              updatedAt
            }
          }
        }
      }
    }
    """
    ) {
      bulkOperation {
        id
        status
      }
  userErrors {
    field
    message
    }
  }
}



Thanks!

0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
623 104 148

This is an accepted solution.

Hey @Conner ,

 

When you mention fetching inventory levels for all stores, do you mean for all locations in which the inventory items can be stocked? If that is the case, then I believe this is the GraphQL Bulk Operations query you need to run:

 

 

mutation {
  bulkOperationRunQuery(
   query: """
   {
  inventoryItems {
    edges {
      node {
        id
        inventoryLevels {
          edges {
            node {
              location {
                address {
                  address1
                  address2
                  city
                  country
                }
                id
              }
              available
              id
              updatedAt
            }
            
          }
        }
      }
    }
  }
  }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

 

 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Conner
Explorer
49 1 9

Thanks so much, @hassain ! That's exactly what I was looking for.

0 Likes
OliOnline
Tourist
5 0 1

Thanks!

0 Likes
Wayne_Foster
Shopify Partner
7 0 0

Hi @hassain - great work on the bulk fetch.  I am looking to retrieve the Product SKU - along with the inventory levels - in a single Bulk API fetch.  I'll then persist this in a local process - to blend the inventory levels that are retrieved from a warehouse solution.  I can then work out the deltas - to push back using the 

inventoryBulkAdjustQuantityAtLocation

mutation.

The approach above seems to be the most elegant way to approach using up to date GraphQL API's - but as for the syntax - I would appreciate some direction... 

0 Likes