Update Product Metafield with MetaObject Entry Through Shopify Flow Based On Product Vendor

Update Product Metafield with MetaObject Entry Through Shopify Flow Based On Product Vendor

SAnderson_GW
New Member
5 0 0

I am trying to use flow to automate population of product metafields upon product creation. 

 

I have a metaobject with a list of entries for each brand (it's a massive list, we stock hundreds of brands) and I want to auto populate the relevant product metafield with the metaobject entry that matches the product vendor of the product. I have set up the metaobject entries so that the Display Name matches the list of Product Vendors in shopify exactly. 

 

The query I've been using in the Value on 'update product metafield' action in Flow is:

 

{% for metafields_item in product.metafields %}
{% if metafields_item.reference.Metaobject.displayName contains product.vendor %}
{{metafields_item.reference.Metaobject.id}}
{% endif %}
{% endfor %}

 

I thought the metaobject.id would return the entry where the display name matches product vendor but it doesn't seem to. Given I have a vendor list in the hundreds (and therefore the same number of metaobject entries) I need a solution that returns a specific entry based on the above condition rather than creating a flow for each vendor that returns a specific entry (i.e. I can't have a gid://shopify/Metaobject/123 in the value field)

 

The returned error on testing the above flow is: 

Screenshot 2024-10-19 at 08.34.04.png

 

Is there a solution to this problem? 

Reply 1 (1)

paul_n
Shopify Staff
1372 153 321

That looks roughly correct. I would use a "Log output" action to test what data is available. I would remove that inner "if" statement and just output the variables like "product.vendor" and the displayName. Your condition appears to not be matching, but it's not clear why until you see the data.

 

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.