Access to product data which is connected to another product via metafield

Topic summary

A developer is attempting to access product data from a linked product using a metafield reference but encountering rendering issues.

The Problem:

  • A metafield stores a product reference (gid://shopify/Product/<product_id>)
  • When trying to access the linked product’s title using {{ sample.title }}, nothing renders
  • The reference itself displays correctly when output directly, confirming the metafield connection works

Proposed Solution:
Shopify Liquid doesn’t natively support dynamically fetching data from referenced products. Two workarounds suggested:

  1. Use Shopify’s Storefront API or GraphQL to query the linked product’s details
  2. Store the title directly in a separate metafield instead of relying on the reference

Current Status:
The original poster acknowledged the GraphQL/Storefront API suggestion as a viable approach for querying all product details. The discussion remains technical and focused on implementation methods.

Summarized with AI on November 3. AI used: claude-sonnet-4-5-20250929.

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

Hi @AlyshaJohnson

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:

  1. Use Shopify’s Storefront API or GraphQL to query the product details, including its title.
  2. Alternatively, pre-store the title directly in another metafield.

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: [email removed]

Phil

Seopro Developer

1 Like

Hi Phil,

Thank you for your suggestion of using Shopify’s Storefront API - I could query all product details!

Kind Regards,

Alysha