Hello, I try to explain my need. I want to include in the product page the metafield collection of that product.
Each product have a product type that matches his collection, so if there is a way to find the collection of the product, I can easy manage it. For example collection.metafields.custom.matefieldname[product.type], sorry I don’t know the syntax
the product will be able to reference a collection. For the moment I’ll assume that’s the scenario we’re talking about.
You’re quite close to the solution so you may have already solved it. One bit of advice would be to turn the product type in a handle first. It’s possible you’ll add a type one day with a special character that’s not support in the metafield key naming convention.
This code would work and assumes as an example that:
The collection is called women’s dresses (the handle will be womens-dresses)
the metafield have the namespace of custom (or whatever you need to use)