we are a provider of categories + attributes or category metafields for products. While we can set category metafields for those option values that we already set in UI, we do not know how to do this programmatically.
E.g. by running this:
{
products(first: 10) {
edges {
node {
id
title
metafields(first: 10) {
edges {
node {
id
namespace
key
value
In other words, the output from our AI is set of attributes and their values in text format. e.g. color:green, sleeve type:long. how do we use these texts as input to creation of metaobjects which we can then link to. for options
If the setting of metafields is not possible using texts as input, can someone point us to another option.
We did manage to implement this feature where we are setting these values under variants sections but probably that would require the changing of template. Another issue is also that the filtering is based on category metafields so will not work with attributes set under variants.
Thanks.
AI developer of 10+ years (Ph.D. in Physics). Main area of work: Smart product categorization, specializing in returning categories and attributes for products in Shopify stores.
Good timing for the question, I’m in the middle of working on this for our bulk editor app.
The category metafields are lists of metaobject references. As you mentioned, the metaobjects that represent different values (eg, size small) are only created when they are first configured in the UI.
You can use the GraphQL API to create these metaobjects yourself and then link to them if they’re not already present in the store.
Hey Daniel! Do you mind pointing to where you see the taxonomy_reference field mentioned in the metaobject docs? Having a hard time figuring out how to link to the preset GIDs from the taxonomy
When you setup a category metafield for a product you’re building a list of connections between the product and metaobjects. For example, this is the XS size metaobject that the ‘Size’ category metafield uses: