How to modify product data queries in Flow?

Hi,

I’ve using flow to getProductData so that I can then add tags to the product based on the MF value.

At the moment I’m just looking at products that were updated in the last day. This is the query for that:

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

What I’d like to do is introduce a few changes.

  • make it so that it checks for things updated in the last 23 hours NOT 1 day (is this as simple as changing “1 day” to “23 hours”? May be, but can’t tell from the docs)

  • the product MUST have a specific tag (lets call that ‘GOOD TAG’)

  • the product MUST NOT have a specific tag (‘BAD TAG’)

  • the product MUST have a specific metafield

I can’t make sense of the docs linked from Flow to know whether this is possible and, if it is, how I’d do it.

Does anyone know?

  • make it so that it checks for things updated in the last 23 hours NOT 1 day (is this as simple as changing “1 day” to “23 hours”? May be, but can’t tell from the docs)

Yes

  • the product MUST have a specific tag (lets call that ‘GOOD TAG’)

  • the product MUST NOT have a specific tag (‘BAD TAG’)

tag:‘GOOD TAG’

tag_not:‘BAD TAG’

  • the product MUST have a specific metafield

Not possible - API queries do not support metafields yet.

Lovely stuff. For what seems like the hundredth time, thank you @paul_n

I want to add a metafield using the shopify flow.
But somehow it doesn’t seem to be possible.
So I set flow to schedule to get product data and add a metafield value when the condition that I set meets.
The condition in the query is this
updated_at:<=‘{{ scheduledAt }}’ AND updated_at:>‘{{ scheduledAt | date_minus: “1 day” }}’ AND compare_at_price != blank

  1. I’m not sure if this part of the condition is correct. I want to check if there’s a compare_at_price.
    compare_at_price != blank

  2. for each returned item I want to add ‘date’ type and value: 1999-11-22 to date type metafield called custom.last_updated.The actual date that I want to add is the product’s last updated date. For test purposes I just want to see if date type metafield is added via flow.

I’m asking this question since I found your answer here saying that ‘API queries do not support metafields yet’.
Can I manipulate products’ metafield using Flow?
Please look into the flow file if you have a chance.
Thank you!

!= is not valid query syntax. See https://shopify.dev/docs/api/usage/search-syntax

You cannot query by the compare at price. Query filters for “Get product data” are here: https://shopify.dev/docs/api/admin-graphql/2024-04/queries/products#argument-query You may have success with “is_price_reduced:true” instead.

After “Get Product Data” you would need to loop over the returned products with “For each”. Inside that loop, you can update the product metafield for each.