Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello,
I have a metaobject structure that can be assigned to either a product or a collection.
By inserting this code (which is the reference for metafield)
{{ product.metafields.custom.keylabels_desc.value | json}}
I receive this output
{"collections":["gid:\/\/shopify\/Collection\/325100830915"],"keylabels":["ferro da stiro","lavatrice","asciugatrice"],"name":"key01","product":["gid:\/\/shopify\/Product\/7726321336515","gid:\/\/shopify\/Product\/7726324515011"],"text":{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":"questa è la key 01"}]}]}}
I would like to either be able to correctly format the output or extract the handle of the metaobject that is being referenced. Is this possible?
I'm assuming .handle doesn't work?
{{ product.metafields.custom.keylabels_desc.value.handle }}
It's hard to say for sure without knowing the structure of your metaobject or at least in your example which the handle is
Hello,
no it doesn't work because that is the metafield through which the metaobject is referenced. The metaobject is key_label and inside it has various fields, such as key_label.keylabels
I have a similar issue. I was able to display the values using a | json filter, but In my case the metafield is set as "list of entries" and I can't find a way ti access each entry.
I just posted mine here: https://community.shopify.com/c/metafields-and-custom-data/acessing-metaobject-data-from-product-met...