We are building an integration to create products through the GraphQL API. When creating a product, we want to also add data for the category-specific metafields but we are having trouble getting the specific metafields for a product based on its category.
As an example, let’s say we want to create a product with the “Shirts” category. We would find the specific category in the taxonomy and look at the attributes. We see the “Color” attribute and we would like to send a value for that.
But from this point, we have no way to determine which metafield namespace and key we need to use in the “createProduct” mutation to populate that value. For this specific example, we know that namespace=“shopify” and key=“color-pattern” but we need to be able to do this automatically.
How can we handle this? Is there a solution that we are missing? Thanks for your help!
Using the TaxonomyAttribute is actually what I’m struggling with. I can’t seem to be able to do anything with it that can lead to the creation of a metafield.
I’ve noticed that what I can do is use the TaxonomyAttribute ID to enable the associated standard metafield definition. I do this by adding 10000 to the TaxonomyAttributeID to obtain the standard metafield id.
However, I’m not sure if this is actually the way I’m supposed to do this considering that this association between the Taxonomy Atrribute and the Standard Metafield Definition is not shared anywhere in the documentation (or maybe I just didn’t find it).