Looking for guidance on building a flow that will update metafields and variant metafields

Solved

Looking for guidance on building a flow that will update metafields and variant metafields

Dave135
Tourist
7 1 2

Hello, I am struggling to get past a few basics to try to build what I believe is possible with the right guidance.

I load multiple Products with up to 100 variants each on a daily basis. After I load these products into Shopify, I must manually, or in bulk, make a number of updates that I believe can be mostly updated automatically with Shopify Flow. Below is the scope of what I am trying to do, some Flows are more basic than others and I am also adding screenshots of my first partially successful test.

 

I would be grateful for any any guidance on any of the below items I am trying to incorporate into this flow.

 

Basic Updates:

1. Update Product Status to: "Draft" - This is the only one I have working correctly so far.

2. Update Variant Metafield: mm-google-shopping.condition [single_line_text_field] to: "new" - in my example, I did not get any errors but nothing seems to have happened. I would expect each variant under the product to be updated with "new" in this field.

3. Update Metafield: mm-google-shopping.custom_product [boolean] to: "TRUE". This action crated a new unstructured metafield with the TRUE status. I believe this is because I can't seem to put the right values in Name Space and Key.

 

Update based on lookups or mapping:

1. Update the Variant Metafield: mm-google-shopping.size [single_line_text_field] with the value from "Option2" which is a variant level field that has the size of the product, for example, S, M, L, XL, etc.

I have several others which I could replicate the logic for if I can figure the first one out.

 

Update based on if statement:

1. Update Variant Metafield: mm-google-shopping.gender [single_line_text_field] - Logic would be (If Option1Value = "Men's T-Shirt", then set value to "male", else if option1Value = "Unisex T-Shirt", OR "Sweatshirt" or "Hoodie" then set to value to "unisex")

2. Update Category: ID based on if statement (If Option1 Value = "Sweatshirt", then set value to "14326", else if option1 value = "Men's T-shirt" then set value to "174". I have several others but just looking for help getting the syntax working correctly.

 

Current Flows Images:

Screenshot 2024-09-11 at 12.51.37 AM.png

Screenshot 2024-09-11 at 12.56.20 AM.pngScreenshot 2024-09-11 at 12.56.26 AM.png

Screenshot 2024-09-11 at 12.56.46 AM.png

Accepted Solution (1)
Dave135
Tourist
7 1 2

This is an accepted solution.

FYI for anyone else trying to do this, I think I have all the flows working smoothly now. Anytime a new product is created or updated, I have about 15+ fields that all update for Google Merchant center. This includes description, meta objects, variant meta fields, product category and product meta fields. I was able to leverage Kalen for help on a couple of the harder ones.

View solution in original post

Replies 9 (9)

PaulMartin
Shopify Partner
624 60 147

Hi Dave.


@Dave135 wrote:

Basic Updates:

1. Update Product Status to: "Draft" - This is the only one I have working correctly so far.

2. Update Variant Metafield: mm-google-shopping.condition [single_line_text_field] to: "new" - in my example, I did not get any errors but nothing seems to have happened. I would expect each variant under the product to be updated with "new" in this field.

3. Update Metafield: mm-google-shopping.custom_product [boolean] to: "TRUE". This action crated a new unstructured metafield with the TRUE status. I believe this is because I can't seem to put the right values in Name Space and Key.


1. No problem there.
2. Your namespace looks correct, just change your key. I assume it would just be googlecustomproduct. No product. and no .value
3. Similar problem to #2

For the others


@Dave135 wrote:

Update based on lookups or mapping:

1. Update the Variant Metafield: mm-google-shopping.size [single_line_text_field] with the value from "Option2" which is a variant level field that has the size of the product, for example, S, M, L, XL, etc.

I have several others which I could replicate the logic for if I can figure the first one out.

 

Update based on if statement:

1. Update Variant Metafield: mm-google-shopping.gender [single_line_text_field] - Logic would be (If Option1Value = "Men's T-Shirt", then set value to "male", else if option1Value = "Unisex T-Shirt", OR "Sweatshirt" or "Hoodie" then set to value to "unisex")

2. Update Category: ID based on if statement (If Option1 Value = "Sweatshirt", then set value to "14326", else if option1 value = "Men's T-shirt" then set value to "174". I have several others but just looking for help getting the syntax working correctly. 

I have no idea how to build each of them. Terribly sorry.

I do know someone who can help you with Flow. You might want to contact Kalen at Shopify Automation As A Service | Flow (flow-helper.com). His work focuses on building Shopify flow so he's very good at it, and I mean very very good. Send him a quick email regarding your problem and he should be able to assist you. Oh, and if you contact him, tell him I sent you.

Dave135
Tourist
7 1 2

Thank Paul,


I was able to get items 1 and 3 under Basic Updates so far.  I have been very confused by the Name Space and Key but I think I finally understand an easy way to look at this is simply that the "." separate them in the field name. 

Dave135
Tourist
7 1 2

This is an accepted solution.

FYI for anyone else trying to do this, I think I have all the flows working smoothly now. Anytime a new product is created or updated, I have about 15+ fields that all update for Google Merchant center. This includes description, meta objects, variant meta fields, product category and product meta fields. I was able to leverage Kalen for help on a couple of the harder ones.

leeprkr
Visitor
1 0 0

Great news @Dave135 

Can you share with the community, so we can try ourselves?

I am also looking to find out how to automate:

 

Age Group

Gender

Size

Condition

Custom 

 

Google Shopping metafields automatically

Dave135
Tourist
7 1 2

Apologies for the delay, I missed the message. Below is a summary of what I did.

Flow 1: Product Created Trigger > Wait 60 seconds 

Branch 1 > Update Product Metafield (metafield namespace: mm-google-shopping, key: custom_product, Value: True, Type: Boolean)

Branch 2 > For each > Update Product variant Metafield (metafield namespace: mm-google-shopping, key: condition, Value: new, Type: single line text)

Branch 3 > For each > Check if Options Value = Hoodie (example) Update Product variant Metafield (metafield namespace: mm-google-shopping, key: gender, Value: unisex, Type: single line text)

Branch 4 > For each > Check if Options Value = Hoodie (example) Update Product variant Metafield (metafield namespace: mm-google-shopping, key: age_group, Value: adult, Type: single line text)

 

The process just repeats for each field you want to update.

 

For other items like linking a size guide or setting the product taxonomy, I had to use the Send Admin API request with the productupdate mutation. The hardest part with this is actually finding the right gid's to make the updates. For example, the inputs for a sweatshirt look like the below. The 14326 is the number that is hard to find. The only "easy" way it to manually set some of the products up and then use the GraphQL App to run a query to pull the info. 

{
"input": {
"id": "{{ product.id }}",
"productCategory": {
"productTaxonomyNodeId": "gid://shopify/ProductTaxonomyNode/14326"
}
}
}

 

I also replicated all the flows to redo all the updates when I update a product in case the values need to change. This was the hardest to make work consistently without an endless loop of updating. For this I had to use MESA with Flow. This is the general "flow".

1. FLOW 1:  Scheduled to run every 15 minutes > get Product Data with following query: updated_at:<='{{ scheduledAt }}' AND updated_at:>'{{ scheduledAt | date_minus: "15 minutes" }}' > for each item in get product data > check if updated at is less than or equal to scheduled at > check if Last Flow Update (Custom metafield) does not exist or is less than updated at > Update Product Metafield custom.last_flow_update_at, value: {{ getProductDataForeachitem.updatedAt | date_plus: "30 minutes" | date: "%Y-%m-%dT%H:%M:%S" }} Then check if updated at is less than or equal to scheduled at > check if Last Flow Update (Custom metafield) does not exist or is less than updated at > Send Product to MESA.

2. MESA: Receive Product from FLOW, Send Product back to FLOW. (As simple as this is, I could not find another way to make it work with FLOW alone.

3. FLOW 2: Send Product from MESA trigger > run all updates.

 

summitsoul
Excursionist
15 1 3

Hello,

 

thank you very much for this info.

Regarding the Taxonomy:

 

How did the request you made to get the Taxonomy code look like? 

I need the one for T-Shirts.

 

I can only find the old ones here: https://web.archive.org/web/20240315110540/https://help.shopify.com/txt/product_taxonomy/en.txt

 

Thank you!

 

Dave135
Tourist
7 1 2

The first thing you have to do is manually add the product category to a listing so that way when you do the API query, it will be able to respond back with the publication ID for that specific product category.

 

This is what you can put into Shopify GraphQL

 

{
publications(first: 10) {
edges {
node {
id
name
handle
publicationType
}
}
}
}

lynth
Shopify Partner
197 11 32

Bump. I'm interested in the product's update. What is your trigger? I think I will build my own custom app based on webhooks, but maybe there is a simpler way with the Flows app.

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Dave135
Tourist
7 1 2

Just about anything is possible in Flow. I use new product created trigger. The more challenging one is running updates when you update a product as they do not have a good trigger for product updates. To work around this, I do a scheduled run, add a bunch of conditions to determine if it’s a valid update, if the conditions are met, I send each product to MESA, and then MESA sends it right back and then I run the update flow off of that.