Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
On the admin page, we can create a product within a selected category. Products in a category can have predefined metafields to choose from. Is there a standard way to access these category metafields through the API?
Hey @wangli29751 this query is relates to Shopify's Product Taxonomy and Category Metafields, a newer feature that helps with product attributes like (material, color, etc.) based on the assigned product category.
When creating products via the GraphQL Admin API, you can access and assign category-based metafields, but there are some important details to keep in mind.
1: Why are category Metafields?
Now the Question is that how to access Category metafield via GraphQL?
There is a standardized way to fetch and use these via GraphQL Admin API. Just follow these steps.
query {
productCategorySuggestions(query: "t-shirt") {
productTaxonomyNode {
id
name
fullName
}
}
}
query {
productTaxonomyNode(id: "gid://shopify/ProductTaxonomyNode/12345") {
id
name
metafieldDefinitions(first: 50) {
edges {
node {
id
name
key
namespace
type {
name
}
}
}
}
}
}
mutation {
productCreate(input: {
title: "Nike Air Max",
productCategory: {
productTaxonomyNodeId: "gid://shopify/ProductTaxonomyNode/12345"
}
}) {
product {
id
title
}
userErrors {
field
message
}
}
}
mutation {
metafieldsSet(metafields: [
{
ownerId: "gid://shopify/Product/PRODUCT_ID",
namespace: "standard",
key: "material",
type: "single_line_text_field",
value: "Cotton"
}
]) {
metafields {
id
key
value
}
userErrors {
field
message
}
}
}
By following these steps you will be able to use category Metafields in Product creation via the GraphQL API.
if this was really helpful prove it via like and Mark as Solution.
Thank you for your reply, but it appears that none of the queries or mutations you provided were valid.
Hi, Wangli
Yes, there is a standard way to access category metafields through the API in various eCommerce platforms like Shopify, WooCommerce, and others. Here, I will explain how you might approach this depending on the platform you are working with. Since many platforms, like Shopify, allow for category-specific metafields, let's start with a more general guide and dive into specifics for Shopify.
There are some categories metafields using these APIs
Shopify and WooCommerce (Wordpress)
Only AI bots here 😪
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025