Change Product Type Based on Tags Using Flow App

Solved

Change Product Type Based on Tags Using Flow App

MelissaN
Visitor
2 0 0

Is there any way (using Flow app) to modify the "Product Type" field for an item based on the tags on that item? For example, an imported item has the tag Patriotic, but the incorrect Product Type of Mom. Can I use flow to change the product type, or can it only be done via the CSV or manually either on the product page or on the bulk edit page?

Thanks!

Accepted Solution (1)

paul_n
Shopify Staff
1726 188 395

This is an accepted solution.

Yes, look at the new action called "Send Admin API request". You'll be able to call "productUpdate" to set the type.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 8 (8)

paul_n
Shopify Staff
1726 188 395

This is an accepted solution.

Yes, look at the new action called "Send Admin API request". You'll be able to call "productUpdate" to set the type.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
VitraCircle
Tourist
9 0 1

Hi There,

Could you please expand upon this please. I have been racking my head trying to get the Product Type to change based on the Tag and I for the life of me cannot figure it out.

Many thanks!

Best, Michael

paul_n
Shopify Staff
1726 188 395

You haven't provided much detail about what you are trying to do. 

 

This is one way to check a tag and then set a product type based on that check. 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
VitraCircle
Tourist
9 0 1

This was exactly what I needed! Thank you so much!

Best, Michael

Marco_MM_PT
Tourist
4 0 1

Hi Paul_n

 

I was trying to follow this great explanation about updating de Product Type (finally I see a way to do this!), but I'm getting an error.

 

I need to change the Product Type based on a Product Tag.

I tried like you showed in the image (in two ways, I was not sure if it was missing a "}"):

Marco_MM_PT_0-1744364822434.png

Marco_MM_PT_1-1744364863986.png

 

But I always get this error:

Marco_MM_PT_2-1744364982393.png

Exception: { "input": { "productType": "Smartphones", "id": "gid://shopify/Product/14950198608247", }
Mutation input evaluated to invalid JSON. Please ensure the input forms valid JSON after Liquid code is run.

Input
{
  "mutation_name": "productUpdate",
  "mutation_input": "{\n  \"input\": {\n    \"productType\": \"Smartphones\",\n    \"id\": \"gid://shopify/Product/14950198608247\",\n    \n}",
  "api_version": "2024-07",
  "hydration_type_patch": "{}"
}

 

Can you help, please? I'm doing something wrong? Can be the case that the way my website code is customized makes me to have the script in a different way?

 

Two more things:

. To change the Vendor is the same way?

. I need to change the Title too, but no all the Title. I need to replace a string in the Title for another string (exp: "Outlet Store1" for "Outlet Store2"). It's possible to do this too? If so, can you show how can be the script, please?

 

Thank you very very much in advance for any help that you can give.  🙂

Bes regards.

paul_n
Shopify Staff
1726 188 395

You have invalid JSON. I think it's the trailing comma after your "id" field. Usually you can just add your code to something like:

https://jsonlint.com/

 

And it will show you the problem.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Marco_MM_PT
Tourist
4 0 1

 

Great! The comma was the problem indeed. Works fine now for Type and Vendor. Thanks! 

{
    "input": {
        "customProductType": "Smartphones",
        "vendor": "Apple",
        "id": "{{ product.id }}"
    }
}

 

And to replace a specific string for another string in the Title, any idea?

I think I have to stringify and parse, but I'm not getting how to associate that with the code for the Title in Flow...

{
    "input": {
        "customProductType": "Smartphones",
        "vendor": "Apple rst",
		"title": "",
        "id": "{{ product.id }}"
    }
}

 

Do you know how to do it?

Thank you very much again for your time!

 

 

Marco_MM_PT
Tourist
4 0 1

OK, I found a way! I'll let it here if someone needs:

{
    "input": {
        "customProductType": "Smartphones",
        "vendor": "Apple",
        "title": "{{ product.title | replace: 'Title String 1', 'Title String 2' }}",
        "id": "{{ product.id }}"
    }
}

 

Thanks!