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:
Is there a solution to this problem?
