Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Stock et SKU

Solved

Stock et SKU

ThomasNRC
Shopify Partner
2 0 0

Hello,

 

We develop C# application for manage stock beetween Shopify and our ERP.

Actually, we search all product and we loop on all variants for getting article with SKU but it s very slowly

 

It is possible to get all product variant with SKU wihtout loop on all variant in all product ?

 

TY

 

 

 

Accepted Solution (1)

CameronMZB
Shopify Partner
9 3 3

This is an accepted solution.

I had/have to do something similar.

First I call a bulkOperationRunQuery to get all the products, then I call currentBulkOperations to check the status, then I get the file when the job is done.

 

Query to get inventory:

{"query":"mutation GetInventory { bulkOperationRunQuery(query: \"{ inventoryItems(first: 5000) { edges { node { id sku inventoryLevels(first: 10) { edges { node { available location { id } } } } } } } }\") { bulkOperation { id status } userErrors { field message } } }"}

 

Query to check status:

{"query":"{currentBulkOperation(type: QUERY) { id status objectCount url } }"}

 

This will eventually return a url where you can download a JSONL file; I just have my script wait for a second, then check, if its not ready, it waits again.

 

I mostly followed the Perform bulk operations with the GraphQL Admin API page; you may need to adjust the first query to better suit your needs.

 

View solution in original post

Reply 1 (1)

CameronMZB
Shopify Partner
9 3 3

This is an accepted solution.

I had/have to do something similar.

First I call a bulkOperationRunQuery to get all the products, then I call currentBulkOperations to check the status, then I get the file when the job is done.

 

Query to get inventory:

{"query":"mutation GetInventory { bulkOperationRunQuery(query: \"{ inventoryItems(first: 5000) { edges { node { id sku inventoryLevels(first: 10) { edges { node { available location { id } } } } } } } }\") { bulkOperation { id status } userErrors { field message } } }"}

 

Query to check status:

{"query":"{currentBulkOperation(type: QUERY) { id status objectCount url } }"}

 

This will eventually return a url where you can download a JSONL file; I just have my script wait for a second, then check, if its not ready, it waits again.

 

I mostly followed the Perform bulk operations with the GraphQL Admin API page; you may need to adjust the first query to better suit your needs.