Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Access product system metafields in liquid?

Access product system metafields in liquid?

Allan_Gourdie
Shopify Partner
20 0 1

How do I access the built in product metafields e.g. gender, age group.

I've tried {{ product.metafields.gender }} etc but that doesn't work.  

I've seen other posts discussing custom metafields and saying to use a namespace e.g. product.metafields.mynamespace.key

I tried guessing various namespaces to no avail e.g. product.metafields.default.gender, product.metafields.product.gender

Any help much appreciated

Replies 5 (5)

HunkyBill
Shopify Partner
4853 60 568

Here is the list of fields and their namespaces. 

MPN - global
UPC - global
ISBN - global
JAN - global
EAN - global

age_group - google
gender - google
google_product_type - google

so you'd try product.metafields.google to see if you had anything of any value at the gender key.

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

Allan_Gourdie
Shopify Partner
20 0 1

Thanks, you are a life saver.  I am now using product.metafields.google.age_group etc

Asif3
Shopify Partner
7 0 1

Hi!

i tried to access "MPN" metafield using {{ product.metafields.global.mpn }} or {{ product.metafields.global.MPN }} but  it didn't work, although it is working for {{ product.metafields.google.gender }}

Please reply asap, as i am going ahead the deadline. Any help will be highly appreciated.

 

Asif

Asif3
Shopify Partner
7 0 1

Hi!

i tried to access "MPN" metafield using {{ product.metafields.global.mpn }} or {{ product.metafields.global.MPN }} but  it didn't work, although it is working for {{ product.metafields.google.gender }}

Please reply asap, as i am going ahead the deadline. Any help will be highly appreciated.

Asif

Allan_Gourdie
Shopify Partner
20 0 1

{{ product.metafields.global.MPN }} works fine for me.

If you try {{ product.metafields.global | to_json }} it will show everything in the global space and show you the keys.