SKU Queries with API

Highlighted
New Member
1 0 0

Hi Everyone,

 

I have done some testing and I'm pretty sure I know what the answer is going to be but will try my luck anyway.

 

Have a client who is setting up a shop on Shopify ( which I love by the way ). As a part of this process they have an internal system for taking payments in store. The plan is to send an XML file to a server which we read and then update the inventory via the REST API which all looks fine. 

 

The big problem I have is finding the product in Shopify. They have SKU codes but alas the SKU on Shopify is suffixed with other elements e.g:

On Shopify: 01-02-034 Diamond SE
SKU Code from feed: 01-02-034

Now I know the REST API does not have an endpoint for grabbing a product by SKU but the GraphQL does. Now am I right in thinking that I cant find a product by a partial SKU code it has to be a complete match.

So I am running this and returns nothing. 

 query {
     ProductVariants(first: 1, query: "sku:01-02-034") {
                                edges {
                                    node {
                                    id
                                    }
                                }
                            }
          }

If I add the rest of it to the SKU then I get a result. 

 

So my question is - Is there a way around this that anyone can think of. My GraphQL is a bit novice to say the least so any direction would be ideal.

 

Cheers in advance

 

Steve

0 Likes
Shopify Staff
Shopify Staff
190 21 21

 

Hey @clarkstudiosuk - nice investigation. Typically with our GraphQL API you are able to do a wildcard search with the * symbol. It would look something like: 

 

{
  productVariants(first: 1, query: "title:sma*") {
    edges {
      node {
        id
      }
    }
  }
}

For SKU however, we are looking for an exact match. I will let you know if anything changes. 

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


0 Likes