Fetching Shopify Item Cost Multiple Calls

Highlighted
Shopify Partner
7 0 0

I'm needing the item cost from Shopify, and I'm having a lot of trouble with getting them. I'm importing the items, but the Item resource does not include the cost. As such, when I do a nightly sync of all items or stores, I have to call the InventoryItem API outlined here: https://help.shopify.com/en/api/reference/inventory/inventoryitem#index-2019-10. This limits to 100 IDs at a time, which is really frustrating. Does anyone know of a way to fetch the item and the cost at the same time or be able to get more costs at a time?

0 Likes
Shopify Staff
Shopify Staff
220 36 37

Hey @Jack_Chan ,

 

The only resource in Shopify to get the unit cost of a product item is through the Inventory Item resource of the Admin API that you have linked to.

 

In order to be able to fetch more than 100 inventory items and their unit costs at once, you can utilize Shopify's Bulk Operations GraphQL API .

 

The bulk operations query you would need to write in order to get all of the inventory items and their unit costs for a Shopify store is as follows:

 

mutation {
  bulkOperationRunQuery(
   query: """
   {
  	inventoryItems {
    edges {
      node {
        id
        sku
        unitCost {
          amount
          currencyCode
        }
      }
    }
  }
  
}
    """
  ) {
    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