Get product data

In workflows that use product data, you can use the Get product data action to retrieve product information from your store.

Configuration

Fields

The Get product data action contains the following fields, which are used to build the query:

Fields used in the Get data actions.
FieldDescription
Sort data byRequired. The parameters by which the data returned by the search query is sorted.
Maximum number of resultsRequired. The maximum amount of results that can be returned by the search query that you select. You can return up to 100 at a time.
QueryRequired. Choose from common queries or select Advanced to create your own.

Query String

This is an example query for getting products that were updated in the last day:

updated_at:<='{{ scheduledAt }}' AND updated_at:>'{{ scheduledAt | date_minus: "1 day" }}'

The updated_at variable is a filter available on the Products query and can be used multiple times or combined with other variables. The scheduledAt Liquid variable is available on workflows that used the Scheduled time trigger. The date_minus Liquid tag is a special Flow tag that allows you to subtract time from a date.

When querying data, it's helpful to know:

  • List of available product filters
  • Queries must follow a certain syntax
  • Query field values are not always documented. In some cases, the values can be found by looking at the API docs. Alternatively, you can often find the field values in the URLs in the Admin when you filter. For example, to find some Order query values, filter the Orders page in the Admin, and then check the URL.
  • You can run or test a query in your shop by using the Shopify GraphiQL app.
  • Be mindful of what happens if your query fails. Often the API will return all results (instead of none).

Returned data

All Get data actions return a list of anywhere from 0 and 100 resources. Depending your use case, you might want to use this data in various ways:

  • If you need to handle each list item individually, such as to add a tag for each, then you can use the For each action.
  • If you need to aggregate data, such as count how many results were returned, then you can use the Count or Sum actions.
  • If you need output the list, such as send an email with all the items, then you can use returned data directly in susbsequent actions.

To access the returned data in steps that follow this action, use the variable named Get product data, which is a list of products. You can use this variable in both conditions and actions. For example, you can send the list of products in a Send internal email action like this:

{% for single_product in GetProductData %}
- {{ single_product.name }}
{% endfor %}

Triggers

You can use this action in any workflow, including the Scheduled time trigger. In a workflow that uses the Scheduled time trigger, the workflow starts at a time that you've specified, rather than as a result of an event. Because there is no specific event in your store or from an app that starts the workflow, there is no data automatically included.

API details

Templates

Add products with a tag to a collection in the future

At a time in the future, get all products with a certain tag and then add them to a collection. View template

Delete inactive products

Delete products with no inventory that have not been updated in a year. View template

Publish products with a certain tag in the future

On a date in the future, get products with a certain tag and publish them. Used Scheduled time trigger and Get product data action. View template

Remove new product tag 90 days after the product was created

Every day, gets up to 100 products that were created more than 90 days ago and which still have the "new" tag. The workflow then removes those tags for each product. View template

Schedule products to be removed from Online Store at the specified date and time

At a single date in the future, remove products from online store by tag, id, or sku. Makes use of Scheduled time trigger, Get Product Data action, For Each loop. View template

Send daily email summary with out of stock products

Every day, gets all the products that have 0 inventory and sends an email summary. Uses Get product data, Scheduled time trigger. View template

Send email notification when variant is added with duplicate SKU

When a new variant is added, looks to see if any other variants use the same SKU. If so, it sends an internal email with links to the products and variants affected. View template

Track product variants that are on sale using a product metafield

Sets a metafield on a product if at least one of its variants is on sale. This can be useful for tracking which products are currently on sale. View template

Can’t find the answers you’re looking for? We’re here to help.