Displaying metafield list with liquid

Short description of issue

I am trying to display product metafield list but its not showing on the website but it shows that the metaobject exists

Reproduction steps

{% if product.metafields.shopify.active-ingredient.list? %}
{% for ingredient in product.metafields.shopify.active-ingredient.value %}
{{ ingredient.product.title }}
{% endfor %}
{% endif %}

Additional info

{% if product.metafields.shopify.active-ingredient.list? %}
{% for ingredient in product.metafields.shopify.active-ingredient.value %}
{{ ingredient.product.title }}
{% endfor %}
{% endif %}

What type of topic is this

Troubleshooting

Hi @vyuba

Can you share the Metafield definition structure and a data example?

This is how it looks like

Hello @vyuba,

In this case, it seems you are not following the metaobject definition and should access the label instead:

{% liquid
  assign ingredient_list = product.metafields.shopify['active-ingredient'].value
  for ingredient in ingredient_list
    echo ingredient.label.value
  endfor
%}

  • Label (label) returns the ingredient name and
  • Base active ingredient (taxonomy_reference) returns the taxonomy value gID

Reminder that you can access the definition via the following URL:

// Active ingredient definition
https://admin.shopify.com/store/[[store_id]]/settings/custom_data/metaobjects/shopify--active-ingredient

// Active ingredient entries
https://admin.shopify.com/store/[[store_id]]/content/metaobjects/entries/shopify--active-ingredient

// All standard definitions
https://admin.shopify.com/store/[[store_id]]/content/metaobjects?standard=true

Hope it helps !

1 Like

Thank youuu, it worked :folded_hands:t4:

1 Like