younifyd
Menu

variants

Query product variants by SKU/key across the catalog.

Use it in a workflow

  1. Add a step and choose the Commercetools connector.
  2. Pick the variants action (under Variants).
  3. Fill in the fields below, then reference the result from later steps as {{variants.response.data}}.

Query

This is the query the action sends by default. Edit it in the step's Query field to change which fields come back.

graphql
query Variants($where: String, $sort: [String!], $limit: Int, $offset: Int, $productId: String) {
  variants(
    where: $where
    sort: $sort
    limit: $limit
    offset: $offset
    productId: $productId
  ) {
    offset
    count
    total
    exists
    results {
      productRef {
        typeId
        id
      }
      product {
        id
        key
        version
        productTypeRef
        productType
        masterData
        skus
        createdAt
        lastModifiedAt
        stateRef
        state
        priceMode
        taxCategoryRef
        taxCategory
        reviewRatingStatistics
        createdBy
        lastModifiedBy
      }
      variantId
      key
      current {
        sku
        images
        assets
      }
      staged {
        sku
        images
        assets
      }
      published
      id
      version
      createdAt
      lastModifiedAt
      createdBy {
        isPlatformClient
        clientId
        externalUserId
        anonymousId
        customerRef
        userRef
        associateRef
        attributedTo
      }
      lastModifiedBy {
        isPlatformClient
        clientId
        externalUserId
        anonymousId
        customerRef
        userRef
        associateRef
        attributedTo
      }
    }
  }
}

Variables

Pass these as a JSON object in the step's Variables field.

wherestring
sortarray<string>
limitnumber
offsetnumber
productIdstring

Queries with specified Product ID

json
{
  "where": "string",
  "sort": [
    "string"
  ],
  "limit": 0,
  "offset": 0,
  "productId": "string"
}

Response

Read the result with {{variants.response.data.data.variants}}. If the API returns errors, the step fails and they are at {{variants.response.data.errors}}.

offsetnumber
countnumber
totalstring
existsboolean
resultsarray<object>
productRefobject
productobject
variantIdobject
keyobject
currentobject
stagedobject
publishedobject
idobject
versionobject
createdAtobject
lastModifiedAtobject
createdByobject
lastModifiedByobject

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

Was this page helpful?