Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop through list.metaobject_reference metafield's not working #1762

Open
Shoufty opened this issue Nov 30, 2023 · 1 comment
Open

loop through list.metaobject_reference metafield's not working #1762

Shoufty opened this issue Nov 30, 2023 · 1 comment

Comments

@Shoufty
Copy link

Shoufty commented Nov 30, 2023

Hello,

I think there is a bug with the list.metaobject_reference in product metafields.

In product, I have a meta field "estate" which is of type : list.metaobject_reference

When i do for example :

{% for myEstate in product.metafields.custom.estate.value %}
    {{ myEstate |  dump }}
{% endfor %}

I have only one entry in the for. But when i do :

{{ product.metafields.custom.estate | dump }}

I have the following print :

["gid://shopify/Metaobject/22999368029","gid://shopify/Metaobject/22999597405","gid://shopify/Metaobject/22999531869","gid://shopify/Metaobject/22999695709"]

I don't understand why it doesn't goes through all attached Estates, and if i do something like:

{{ product.metafields.custom.estate.value | json }}

It show me the first referenced metaobject, but i cannot access any other one..

Any one has the same problem ? Is it a bug ? Base on documentation i should be able to iterate through all values.

But this is not working at this time.

Many thanks for any help 😄

@ryansilva
Copy link

ryansilva commented Jan 27, 2024

@Shoufty if you haven't found a solution or anyone else has this issue, the below snippet allows you to loop through the metaobject_reference that has list as a field on the metaobject.

{%- for myEstate in product.metafields.custom.estate.value['fieldNameFromMetaobject'].value -%}
        {{ myEstate }}
 {%- endfor -%}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants