Personalized checkout and custom promotions with Shopify Scripts
Good afternoon community,
I am trying to access the data of a product that is connected to another, via a metafield.
I have added the metafield to the product, as below:
I want to access the title of the 'sample' on the product page, to do this I have added:
{% assign sample = product.metafields.custom.sample2 %}
{{ sample.title }}
However, nothing appears. I know the reference I am using is correct as when I add '{{ sample }}' to the code, I get "gid://shopify/Product/<product_id>" rendered on the page. Usually adding '.value' works for metafields, variants or media, but nothing renders.
Let me know if you need anything further information from me.
Many thanks,
Alysha
Solved! Go to the solution
This is an accepted solution.
It seems the issue is related to accessing the title of the linked product through the metafield. The value gid://shopify/Product/<product_id> confirms the reference is being fetched, but Shopify Liquid doesn't natively allow fetching data from another product dynamically.
Here’s how you can resolve it:
If you're aiming to optimize your product pages for SEO, tools like SEOPro can help identify and resolve SEO issues effectively. It audits products, suggests improvements, and offers bulk optimization features, making it easier to enhance your SEO strategy.
Full disclosure: We are the developer of this app. Feel free to reach out to us: support@seo-pro.app
Phil
Seopro Developer
This is an accepted solution.
It seems the issue is related to accessing the title of the linked product through the metafield. The value gid://shopify/Product/<product_id> confirms the reference is being fetched, but Shopify Liquid doesn't natively allow fetching data from another product dynamically.
Here’s how you can resolve it:
If you're aiming to optimize your product pages for SEO, tools like SEOPro can help identify and resolve SEO issues effectively. It audits products, suggests improvements, and offers bulk optimization features, making it easier to enhance your SEO strategy.
Full disclosure: We are the developer of this app. Feel free to reach out to us: support@seo-pro.app
Phil
Seopro Developer
Hi Phil,
Thank you for your suggestion of using Shopify's Storefront API - I could query all product details!
Kind Regards,
Alysha
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024