Skip to main content

removeProductsFromCategory

Requires permission products:product:update.

Detach products from a category. Only products currently in this category are affected; the product's other categories are untouched.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation RemoveProductsFromCategory($categoryId: ID!, $productIds: [ID!]!) {
removeProductsFromCategory(categoryId: $categoryId, productIds: $productIds) {
changedCount
skippedCount
category {
id
code
name
createdAt
childrenCount
deletedAt
}
}
}

Variables:

{
"categoryId": "id",
"productIds": [
"id"
]
}

Response:

{
"data": {
"removeProductsFromCategory": {
"changedCount": 0,
"skippedCount": 0,
"category": {
"id": "id",
"code": "string",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"childrenCount": 0,
"deletedAt": "2025-01-15T00:00:00Z"
}
}
}
}
removeProductsFromCategory(
categoryId: ID!
productIds: [ID!]!
): CategoryProductAssignmentResult!

Arguments​

removeProductsFromCategory.categoryId ● ID! non-null scalar​

The ID of the category.

removeProductsFromCategory.productIds ● [ID!]! non-null scalar​

The IDs of the products.

Type​

CategoryProductAssignmentResult object​

The result of adding existing products to a category, or removing them.