Get Product Data in Shopify Flow using a list of IDs

Topic summary

A user needed to query multiple products by ID in Shopify Flow’s ‘Get Product Data’ action to add a ‘sold out’ tag. They had a list of product IDs as a string but struggled with the correct query syntax.

Solution provided:

  • Use a simple query string format: (id:8258451439838) OR (id:8258451439835)
  • The query follows standard search syntax documented in Shopify’s Admin GraphQL API
  • Flow automatically returns product ID and title for later use in the workflow

Key resources:

  • Shopify’s product query filter documentation
  • Flow’s Get Product Data action reference page

Outcome: The suggested query syntax worked perfectly, resolving the issue and completing the user’s complex workflow.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

I’m working on quite the complex Shopify Flow. I’ll spare you the details of the calculations before this point, but I essentially have a list of product IDs structured as such, as a string:
[“gid://shopify/Product/8258451439839”, “gid://shopify/Product/8258451439838”]

I would now like to use the ‘get product data’ action to get the products with the matching IDs, and then add a tag ‘sold out’ to those products. I just can’t seem to figure out how to write the advanced query on that ‘get product data’ action. I tried a few options below from other resources, but none seemed to work…

This is the last part of quite the extensive shopify flow that is now working perfectly, and I’d hate for it to now go wrong at that last step…

query Products($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Product {
      id
      title
      images (first: 1){
        nodes {
          url(transform: {maxHeight: 80, maxWidth: 80})
        }
      }
    }
  }
}

variables: {"ids": ["gid://shopify/Product/8153588367651", "gid://shopify/Product/8153588465955", "gid://shopify/Product/8153588793635", "gid://shopify/Product/8153588695331", "gid://shopify/Product/8153589023011"]}
query MyQuery {
  products(first: 20, query: "(id:8042415816983) OR (id:8105484845335)") {
    edges {
      node {
        title
        id
      }
    }
  }
}
1 Like

Look at the other examples in the Get Product Data action. The query is a fairly simple string. Docs for available filters are here:

https://shopify.dev/docs/api/admin-graphql/2024-01/queries/products#argument-query-filter-id

We have a doc page for this action here which links to the filters and search syntax

https://help.shopify.com/en/manual/shopify-flow/reference/actions/get-product-data

TL;DR - I think that you can take that query above and reuse:

(id:8042415816983) OR (id:8105484845335)

Flow will automatically return the title and ID if you use it later in the workflow.

2 Likes

Thanks, this worked perfectly!