Cant get data from a metaobject to appear on a product page

Short description of issue

Cant access data within a metafield metaobject on a product page

Link to Shopify Store

Reproduction steps

have tried accessing the data with .value method, and directly but returns a list of gids a single line of text and not as an array of usable data.

Additional info

Using the horizon theme to create a list of specific product features for each product, with a metafield thats a metaobject. We can see the metaobject but cant get data out of it. A 'shopify.ui.metaobjects` lookup failed. Cant access directly with the "gid://shopify/Metaobject/411470561667

What type of topic is this

Bug report

Hello @Supawell,

I don’t see the location of the problem but here is how it should be done:

{% liquid
  # If on product template, you have the reference, otherwise
  assign product_reference = section.settings.product

  assign metaobject_reference = product_reference.metafields.namespace.key.value
  assign field_value = metaobject_reference.field_handle.value
  # Or if richtext field → metaobject_reference.field_handle | metafield_tag
%}

That should be everything you need !

Hope it helps :slight_smile:

1 Like

Thank you so much teamdijon.

We’ve tried exactly your solution for a while now but I dont think I explained the problem clearly enough. for each product, I have a series of product features. I sell yoga mats, and so some mats are a combination of grippy, supportive, eco friendly, illustrated by artists etc and each product will have 2-3 of these features shown on the product page.

I have one field, a custom.product_feature, which can reference a list of metaobjects. Each metaobject (one product feature) has a title, description and image to illustrate the feature. I’m hoping the code can find this metafield (it can!) and iterate through each metaobject and read and display in a section (my code cant currently access the content) with the .value attribute returning an empty list.

We can get the gids of the metaobjects as a text string (“{{ product.metafields.custom.product_feature }} returns [“gid://shopify/Metaobject/411470561667”,“gid://shopify/Metaobject/411471675779”,“gid://shopify/Metaobject/411478393219”,“gid://shopify/Metaobject/411779432835”]”), so the content is there but not available to us it seems!

Its very frustrating. the horizon theme should be the primary theme that supports this functionality… so I’m guessing it must be our code!!

Thanks again for your input

Thank you for your help @teamdijon

Silly error, i was using a {%- if features_list.size > 0 -%} check before outputting, where my list of metaobjects = features_list. This size attribute doesnt seem to exist.. simply changing to != blank works

before iterating through with

{% for product_feature in features_list %}

{{ product_feature.feature_title }}

  <p>{{ product_feature.feature_decription }}</p>

  <img src="{{ product_feature.feature_image_video.value | image_url: width: 10 }}" alt="{{ product_feature.feature_image_video.value.alt | default: product_feature.feature_title }}">

{% endfor %}

Thank you