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

Topic summary

Goal: Auto-populate a product metafield at product creation with a Metaobject entry that matches the product’s Vendor, using Shopify Flow.

Context: A Metaobject holds entries for hundreds of brands. Each entry’s Display Name exactly matches a Product Vendor. The Flow “Update product metafield” action should set the metafield to the matching Metaobject entry.

Attempted approach: A Liquid loop over product.metafields checks for a metaobject reference whose displayName contains product.vendor, then outputs the Metaobject id to use as the value. An error occurs (screenshot provided), and the value is not set.

Constraints: Cannot hardcode a single Metaobject ID per vendor due to scale; needs a dynamic lookup based on vendor.

Latest guidance: Another participant says the approach looks roughly correct. They recommend adding a “Log output” action to inspect available data, temporarily removing the if condition, and logging product.vendor and the entry displayName to identify why the condition isn’t matching.

Status: No confirmed solution yet. Next step is debugging via Flow logs to verify variable values and matching logic.

Summarized with AI on December 15. AI used: gpt-5.

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?

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.