assignProductsToBrand
Requires permission products:brand:update.
Assign existing products to a brand. Products already on another brand are moved; ones already on this brand are skipped. Needs the brands update permission.
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:
- GraphQL
- cURL
mutation AssignProductsToBrand($brandId: ID!, $productIds: [ID!]!) {
assignProductsToBrand(brandId: $brandId, productIds: $productIds) {
changedCount
reassignedCount
skippedCount
brand {
id
code
name
createdAt
deletedAt
deletedBy
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation AssignProductsToBrand($brandId: ID!, $productIds: [ID!]!) {\n assignProductsToBrand(brandId: $brandId, productIds: $productIds) {\n changedCount\n reassignedCount\n skippedCount\n brand {\n id\n code\n name\n createdAt\n deletedAt\n deletedBy\n }\n }\n}",
"variables": {
"brandId": "id",
"productIds": [
"id"
]
}
}
EOF
Variables:
{
"brandId": "id",
"productIds": [
"id"
]
}
Response:
{
"data": {
"assignProductsToBrand": {
"changedCount": 0,
"reassignedCount": 0,
"skippedCount": 0,
"brand": {
"id": "id",
"code": "string",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"deletedAt": "2025-01-15T00:00:00Z",
"deletedBy": "string"
}
}
}
}
assignProductsToBrand(
brandId: ID!
productIds: [ID!]!
): BrandProductAssignmentResult!
Arguments
assignProductsToBrand.brandId ● ID! non-null scalar
The ID of the brand.
assignProductsToBrand.productIds ● [ID!]! non-null scalar
The IDs of the products.
Type
BrandProductAssignmentResult object
The result of assigning existing products to a brand, or removing them.