Access product attributes of product linked by metafield

Hi,

I have a product metafield that connects products. That is, on a product there is a ‘product’ type metafield where you can select another product that it has a connection to.

I want to be able to access the metafields of the product linked in the metafield.

Let’s say the metafield is called ‘product.metafields.custom.linked_product’

I need to reference the metafields of the linked product. To get the product ID I just use product.metafields.custom.linked_product

but if I want to get the metafields on that product i would expect to use product.metafields.custom.linked_product.product.metafields.custom.{{key}}

That always returns empty though.

So…the question is, when using a product type metafield can you then access any of the attributes of that product in code?

The following: product.metafields.custom.linked_product.id produces a correct output?

Nope. Sadly not.

Having looked at it a bit further I think assigning a variable with .value on it allows you to then look at the attributes on the referenced product.

Only got that after experimenting with what you said, so thank you very much.