How to access product metafields in homepage?

Gunasekaran
Shopify Partner
16 0 2

Hi, I have created metafields and working fine in product page. I want to use metafield in Features Porduct Section, but i am unable to find a solution for that. Please help me on this issue.

i have found the below one for pages

{% assign the_handle = page.handle %}
{{ pages.the_handle.metafields.global.logo }}

Same i need for products metafield.

Thanks,

Replies 2 (2)
LitCommerce
Trailblazer
295 73 73

Hi @Gunasekaran,

You just need to get it like in the product page, it will work fine. And note it must be get under assign product.
Ex: https://i.imgur.com/yHeYrq2.png
Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
stratify
Shopify Staff
15 1 7

Hi @Gunasekaran – Strat here from Shopify

Product metafields can be rendered whenever you have a product object using liquid. For example, within a featured product section you would need to loop over a collection of products and get the metafields for each one. Here's a simplified example:

{% for product in collection %}
  {{ product.metafields.namespace.key }}
{% endfor %}

 

If you want to target specific products without a collection you can do so using the all_products global object. You can retrieve any product object if you know it's handle:

{{ all_products['insert_product_handle'].metafields.namespace.key }}

 

I hope that's helpful!