Shopify Liquid - Can You Get A Specific Page's Metafields On A Product Page?

- 1 answer

I have a product page in my store. All my products have an associated vendor. For each vendor, I have a custom Shopify page and on this page is attached several metafields. Metafields include things like the vendor (company) country, year founded, etc...

On my product page, I would like to show the above info about the vendor. I can get to the metafields for the vendor if I was on the custom vendor page by using something like:

{% assign vendor_country = %}

Is there anyway to get the same metafield info if I was on a product page? In this case, the context of the Liquid page variable would not be correct by default. I need a way to set this context based on the product.vendor variable and then request the custom vendor page data.



This is possible if you know the page handle. To do so you will have to make use of pages global object. So just get a page by handle and then call the metafields.

Example Code in Product template

{{ pages['page-handle'].metafields.namespace.fieldName }}

Global Pages Object