Menu
updateVariant
Update an existing variant — pass its current version and an array of update actions.
Use it in a workflow
- Add a step and choose the Commercetools connector.
- Pick the updateVariant action (under Update).
- Fill in the fields below, then reference the result from later steps as
{{updatevariant.response.data}}.
Query
This is the mutation the action sends by default. Edit it in the step's Query field to change which fields come back.
mutation UpdateVariant($id: String, $key: String, $actions: [VariantUpdateAction!]!, $version: Long!) {
updateVariant(id: $id, key: $key, actions: $actions, version: $version) {
productRef {
typeId
id
}
product {
id
key
version
productTypeRef {
typeId
id
}
productType {
key
name
description
id
version
createdAt
lastModifiedAt
createdBy
lastModifiedBy
}
masterData {
current
staged
published
hasStagedChanges
}
skus
createdAt
lastModifiedAt
stateRef {
typeId
id
}
state {
id
version
key
type
roles
nameAllLocales
descriptionAllLocales
builtIn
transitionsRef
transitions
initial
createdAt
lastModifiedAt
createdBy
lastModifiedBy
}
priceMode
taxCategoryRef {
typeId
id
}
taxCategory {
name
description
rates
key
id
version
createdAt
lastModifiedAt
createdBy
lastModifiedBy
}
reviewRatingStatistics {
averageRating
highestRating
lowestRating
count
ratingsDistribution
}
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef
userRef
associateRef
attributedTo
}
}
variantId
key
current {
sku
images {
url
dimensions
label
}
assets {
id
key
sources
nameAllLocales
descriptionAllLocales
tags
custom
}
}
staged {
sku
images {
url
dimensions
label
}
assets {
id
key
sources
nameAllLocales
descriptionAllLocales
tags
custom
}
}
published
id
version
createdAt
lastModifiedAt
createdBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
lastModifiedBy {
isPlatformClient
clientId
externalUserId
anonymousId
customerRef {
typeId
id
}
userRef {
typeId
id
}
associateRef {
typeId
id
}
attributedTo {
clientId
source
userRef
}
}
}
}
Variables
Pass these as a JSON object in the step's Variables field.
{
"actions": [
{
"publish": {
"dummy": "string"
},
"unpublish": {
"dummy": "string"
},
"removeStagedChanges": {
"dummy": "string"
},
"removeAsset": {
"assetId": "string",
"assetKey": "string",
"staged": "string"
},
"addExternalImage": {
"image": "string",
"staged": "string"
},
"addAsset": {
"asset": "string",
"staged": "string",
"position": "string"
},
"changeAssetName": {
"name": "string",
"staged": "string",
"assetKey": "string",
"assetId": "string"
},
"changeAssetOrder": {
"assetOrder": "string",
"staged": "string"
},
"removeImage": {
"imageUrl": "string",
"staged": "string"
},
"setAssets": {
"assets": "string",
"staged": "string"
},
"setAttribute": {
"name": "string",
"value": "string",
"staged": "string"
},
"setAttributes": {
"attributes": "string",
"staged": "string"
}
}
],
"version": "string",
"id": "string",
"key": "string"
}
Response
Read the result with {{updatevariant.response.data.data.updateVariant}}. If the API returns errors, the step fails and they are at {{updatevariant.response.data.errors}}.
Need more? See the Commercetools guide for connection setup and behaviour shared by every action.
Was this page helpful?