younifyd
Menu

updateVariant

Update an existing variant — pass its current version and an array of update actions.

Use it in a workflow

  1. Add a step and choose the Commercetools connector.
  2. Pick the updateVariant action (under Update).
  3. 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.

graphql
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.

idstring

Queries with specified ID

keystring

Queries with specified key

actionsarray<object>required
publishobject1 fields
unpublishobject1 fields
removeStagedChangesobject1 fields
removeAssetobject3 fields
addExternalImageobject2 fields
addAssetobject3 fields
changeAssetNameobject4 fields
changeAssetOrderobject2 fields
removeImageobject2 fields
setAssetsobject2 fields
setAttributeobject3 fields
setAttributesobject2 fields
setImagesobject2 fields
setKeyobject1 fields
setSkuobject2 fields
setAssetCustomFieldobject5 fields
setAssetCustomTypeobject7 fields
setAssetDescriptionobject4 fields
setAssetKeyobject3 fields
setAssetSourcesobject4 fields
setAssetTagsobject4 fields
versionstringrequired
json
{
  "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}}.

productRefobject
typeIdstring
idstring
productobject
idstring
keystring
versionstring
productTypeRefobject2 fields
productTypeobject9 fields
masterDataobject4 fields
skusarray<object>
createdAtstring
lastModifiedAtstring
stateRefobject2 fields
stateobject15 fields
priceModestring

One ofEmbeddedStandalone

taxCategoryRefobject2 fields
taxCategoryobject10 fields
reviewRatingStatisticsobject5 fields
createdByobject8 fields
lastModifiedByobject8 fields
variantIdnumber
keystring
currentobject
skustring
imagesarray<object>
assetsarray<object>
stagedobject
skustring
imagesarray<object>
assetsarray<object>
publishedboolean
idstring
versionstring
createdAtstring
lastModifiedAtstring
createdByobject
isPlatformClientboolean
clientIdstring
externalUserIdstring
anonymousIdstring
customerRefobject2 fields
userRefobject2 fields
associateRefobject2 fields
attributedToobject3 fields
lastModifiedByobject
isPlatformClientboolean
clientIdstring
externalUserIdstring
anonymousIdstring
customerRefobject2 fields
userRefobject2 fields
associateRefobject2 fields
attributedToobject3 fields

Need more? See the Commercetools guide for connection setup and behaviour shared by every action.