I inspected all apis made available by shopify and could not find any that exposes product category. would like to send the taxonomy from my erp to shopify
E.g. for a product of type = hats i want to set programmatically via a put or patch request the category to gid://shopify/TaxonomyCategory/aa-2-17.
Hey @Silviu_Virlan! Remy is spot on here - the category field on productSet is what you need, and the GID format you already have (gid://shopify/TaxonomyCategory/aa-2-17) is correct.
Here’s an example:
mutation {
productSet(
input: {
category: "gid://shopify/TaxonomyCategory/aa-2-17"
},
identifier: {
id: "gid://shopify/Product/YOUR_PRODUCT_ID"
}
) {
product {
id
category {
id
name
}
}
userErrors {
field
message
}
}
}
Good question, productUpdate would work just as well here for setting the category. I recommended productSet mainly because the OP’s use case is syncing taxonomy data from an ERP into Shopify, which is the exact scenario productSet was built for. It handles create-or-update in a single operation, so if you’re pushing product data from an external source you don’t need to check whether the product already exists first.
For a straightforward category update on a product you know exists, productUpdate with ProductUpdateInput is perfectly fine and arguably simpler.