Product Variations

For the past 3 years, Shieldware, Inc. has been using the Cleverbridge platform to manage its product information. This has created certain challenges for their sales team, who frequently need to rely on Salesforce for product information and don't have time to cross-check this information with the data in the platform. To save time and ensure that the sales team always has accurate product and pricing information, Shieldware decides to invest development efforts into integrating their Salesforce account with the Cleverbridge GraphQL API. This integration allows the Shieldware e-commerce manager to manage all of Shieldware's products from within Salesforce itself, without having to open the Commerce Assistant. Since Salesforce is now the single source of truth of Shieldware's product information, it also ensures that they always have access to the most up-to-date information about their products.

You can use the GraphQL API to manage your product variations in the following ways:

View Information for one of your Product Variations

View a Text Element

To get the data stored in the Cleverbridge platform for a text element, use the textElement query object. You must provide the id of the text element and specify the fields you would like to return.

Example Request

query {
  textElement(id: 1808) {
    baseLanguage {
      isoCode
      name
    }
    id
    name
    texts {
      language {
        isoCode
        name
      }
      value
    }
  }
}

The API call returns the textElement object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "textElement": {
      "baseLanguage": {
        "isoCode": "en",
        "name": "English"
      },
      "id": 1808,
      "name": "Version",
      "texts": [
        {
          "language": {
            "isoCode": "en",
            "name": "English"
          },
          "value": "Version"
        },
        {
          "language": {
            "isoCode": "de",
            "name": "German"
          },
          "value": "Version"
        },
        {
          "language": {
            "isoCode": "ru",
            "name": "Russian"
          },
          "value": "Версия"
        },
        {
          "language": {
            "isoCode": "ja",
            "name": "Japanese"
          },
          "value": "バージョン"
        }
      ]
    }
  }
}

View a Product Characteristic

To get the data stored in the Cleverbridge platform for a product characteristic, use the productCharacteristic query object. You must provide the id of the product characteristic and specify the fields you would like to return.

Example Request

query {
  productCharacteristic(id: 1182) {
    name
    controlType {
      id
      name
    }
    headerTextElement {
      id
      name
      baseLanguage {
        isoCode
        name
      }
      texts {
        language {
          isoCode
          name
        }
        value
      }
    }
    options {
      name
      runningNumber
      textElement {
        id
        name
      }
      productCharacteristic {
        id
        name
      }
    }
  }
}

The API call returns the productCharacteristic object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "productCharacteristic": {
      "name": "Internet Security",
      "controlType": {
        "id": "RADIO_GROUP",
        "name": "Radio Group"
      },
      "headerTextElement": {
        "id": 1807,
        "name": "Basic",
        "baseLanguage": {
          "isoCode": "en",
          "name": "English"
        },
        "texts": [
          {
            "language": {
              "isoCode": "de",
              "name": "German"
            },
            "value": "Basic"
          },
          {
            "language": {
              "isoCode": "en",
              "name": "English"
            },
            "value": "Basic"
          },
          {
            "language": {
              "isoCode": "ru",
              "name": "Russian"
            },
            "value": "Базовая "
          },
          {
            "language": {
              "isoCode": "ja",
              "name": "Japanese"
            },
            "value": "基本"
          }
        ]
      },
      "options": [
        {
          "name": "two",
          "runningNumber": 2,
          "textElement": {
            "id": 1809,
            "name": "Basic Extended"
          },
          "productCharacteristic": {
            "id": 1714,
            "name": "Internet Security"
          }
        },
        {
          "name": "three",
          "runningNumber": 3,
          "textElement": {
            "id": 1810,
            "name": "Professional"
          },
          "productCharacteristic": {
            "id": 1714,
            "name": "Internet Security"
          }
        },
        {
          "name": "one",
          "runningNumber": 1,
          "textElement": {
            "id": 1807,
            "name": "Basic"
          },
          "productCharacteristic": {
            "id": 1714,
            "name": "Internet Security"
          }
        },
        {
          "name": "four",
          "runningNumber": 4,
          "textElement": {
            "id": 1808,
            "name": "Version"
          },
          "productCharacteristic": {
            "id": 1714,
            "name": "Internet Security"
          }
        }
      ]
    }
  }
}

View a Product Selection

To get the data stored in the Cleverbridge platform for a product selection, use the productSelection query object. You must provide the id of the product selection and specify the fields you would like to return.

Example Request

query {
  productSelection(id: 3038) {
    id
    name
    position {
      id
      name
    }
    useProductNames
    items {
      position
      productCharacteristicOption {
        runningNumber
        name
        productCharacteristic {
          id
          name
        }
      }
      productSelection {
        id
        name
      }
      product {
        id
        names {
          language {
            isoCode
          }
          value
        }
      }
      textElement {
        id
        name
      }
    }
    displayNames {
      language {
        isoCode
      }
      value
    }
    additionalNameInformation {
      language {
        isoCode
      }
      value
    }
    seoUrl
    mediumProductImages {
      clientWebbinary {
        id
        name
        path
        size
        bytes
      }
      language {
        isoCode
      }
    }
    shortDescriptions {
      language {
        isoCode
      }
      value
    }
  }
}

The API call returns the productSelection object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "productSelection": {
      "id": 3038,
      "name": "Version in Cart",
      "position": {
        "id": "SEPARATE_COLUMN",
        "name": "Separate column"
      },
      "useProductNames": false,
      "items": [
        {
          "position": 1,
          "productCharacteristicOption": {
            "runningNumber": 1,
            "name": "Basic",
            "productCharacteristic": {
              "id": 1182,
              "name": "Version in Cart"
            }
          },
          "productSelection": {
            "id": 3038,
            "name": "Version in Cart"
          },
          "product": {
            "id": 97770,
            "names": [
              {
                "language": {
                  "isoCode": "de"
                },
                "value": "Internet Security Basic"
              },
              {
                "language": {
                  "isoCode": "en"
                },
                "value": "Internet Security Basic"
              }
            ]
          },
          "textElement": null
        },
        {
          "position": 2,
          "productCharacteristicOption": {
            "runningNumber": 2,
            "name": "Basic Extended",
            "productCharacteristic": {
              "id": 1182,
              "name": "Version in Cart"
            }
          },
          "productSelection": {
            "id": 3038,
            "name": "Version in Cart"
          },
          "product": {
            "id": 97771,
            "names": [
              {
                "language": {
                  "isoCode": "en"
                },
                "value": "Internet Security Basic Extended"
              },
              {
                "language": {
                  "isoCode": "de"
                },
                "value": "Internet Security Basic Extended"
              }
            ]
          },
          "textElement": null
        },
        {
          "position": 3,
          "productCharacteristicOption": {
            "runningNumber": 3,
            "name": "Professional",
            "productCharacteristic": {
              "id": 1182,
              "name": "Version in Cart"
            }
          },
          "productSelection": {
            "id": 3038,
            "name": "Version in Cart"
          },
          "product": {
            "id": 97772,
            "names": [
              {
                "language": {
                  "isoCode": "en"
                },
                "value": "Internet Security Professional"
              },
              {
                "language": {
                  "isoCode": "de"
                },
                "value": "Internet Security Professional"
              }
            ]
          },
          "textElement": null
        },
        {
          "position": 4,
          "productCharacteristicOption": {
            "runningNumber": 4,
            "name": "Enterprise",
            "productCharacteristic": {
              "id": 1182,
              "name": "Version in Cart"
            }
          },
          "productSelection": {
            "id": 3038,
            "name": "Version in Cart"
          },
          "product": {
            "id": 97773,
            "names": [
              {
                "language": {
                  "isoCode": "de"
                },
                "value": "Internet Security Enterprise"
              },
              {
                "language": {
                  "isoCode": "en"
                },
                "value": "Internet Security Enterprise"
              }
            ]
          },
          "textElement": null
        }
      ],
      "displayNames": [
        {
          "language": {
            "isoCode": "en"
          },
          "value": "Product Selection Display Name"
        }
      ],
      "additionalNameInformation": [
        {
          "language": {
            "isoCode": "en"
          },
          "value": "Product Selection Additional Name Information"
        }
      ],
      "seoUrl": null,
      "mediumProductImages": [
        {
          "clientWebbinary": {
            "id": 58430,
            "name": "GenericBoxshotBlueMedium.png",
            "path": "/mycontent/864/GenericBoxshotBlueMedium.png",
            "size": "100 x 130",
            "bytes": 12710
          },
          "language": {
            "isoCode": "en"
          }
        }
      ],
      "shortDescriptions": [
        {
          "language": {
            "isoCode": "en"
          },
          "value": "Product Selection short description"
        }
      ]
    }
  }
}

Create a Product Variation

Shieldware, Inc. sells anti-virus software for personal and professional use. They sell their product Internet Security in four different versions:

  • Basic
  • Basic Extended
  • Professional
  • Enterprise

Shieldware wants to set up a product variation so that customers can select one of the four software versions.

Create a Text Element

The Version product characteristic has the following individual text elements:

  • Version (displays as a header above the options)
  • Basic (displays as an option that customers select)
  • Basic Extended (displays as an option that customers select)
  • Professional (displays as an option that customers select)
  • Enterprise (displays as an option that customers select)

To create a new text element, use the createTextElement mutation object. To successfully make this call, you must provide all fields of the object.

Example Request

mutation {
  createTextElement(
    input: {
      clientId: 864
      baseLanguageId: EN
      name: "Version"
      texts: [{ value: "Version", languageId: EN }]
    }
  ) {
    createdTextElement {
      id
    }
  }
}

The API call returns the createTextElement object with the requested fields.

Example Response

{
  "data": {
    "createTextElement": {
      "createdTextElement": {
        "id": 1808
      }
    }
  }
}

Create a Product Characteristic

The product variation is for different versions of a product. A product characteristic is set up for Version, with the following four options:

  • Basic
  • Basic extended
  • Professional
  • Enterprise

To create a new product characteristic, use the createProductCharacteristic mutation object. To successfully make this call, you must provide information for all fields of the object, except for headerTextElementId and options.

Example Request

mutation {
  createProductCharacteristic(
    input: {
      name: "Internet Security"
      clientId: 864
      controlType: RADIO_GROUP
      headerTextElementId: 1808
      options: [
        { name: "Basic", textElementId: 1807 }
        { name: "Basic Extended", textElementId: 1809 }
        { name: "Professional", textElementId: 1810 }
        { name: "Enterprise", textElementId: 1811 }
      ]
    }
  ) {
    createdProductCharacteristic {
      id
    }
  }
}

The API call returns the createProductCharacteristic object with the requested fields.

Example Response

{
  "data": {
    "createProductCharacteristic": {
      "createdProductCharacteristic": {
        "id": 1714
      }
    }
  }
}

Create a Product Selection

The product Internet Security is assigned to the Version product characteristic. Whenever Internet Security is added to the cart, the Version product characteristic displays with the four product options.

To create a new product selection, use the createProductSelection mutation object. To successfully make this call, certain fields are required, including clientId, name, and position.

Example Request

mutation {
  createProductSelection(
    input: {
      clientId: 864
      name: "Version in Cart"
      position: SEPARATE_COLUMN
      useProductNames: false
      items: [
        {
          productCharacteristicOptionId: 3962
          productId: 97770
          textElementId: 1807
        }
        {
          productCharacteristicOptionId: 3961
          productId: 9771
          textElementId: 1809
        }
        {
          productCharacteristicOptionId: 3960
          productId: 97772
          textElementId: 1810
        }
        {
          productCharacteristicOptionId: 3959
          productId: 97773
          textElementId: 1811
        }
      ]
      displayNames: [
        { value: "Product Selection Display Name", languageId: EN }
      ]
      additionalNameInformation: [
        {
          value: "Product Selection Additional Name Information"
          languageId: EN
        }
      ]
      seoUrl: "antivirus-security-removecookie"
      mediumProductImages: [{ referencedId: 58430, languageId: EN }]
      shortDescriptions: [
        { value: "Product Selection short description", languageId: EN }
      ]
    }
  ) {
    createdProductSelection {
      id
    }
  }
}

The API call returns the createProductSelection object with the requested fields.

Example Response

{
  "data": {
    "createProductSelection": {
      "createdProductSelection": {
        "id": 3038
      }
    }
  }
}

Delete a Product Variation

Delete a Text Element

You can use the GraphQL API to delete a text element from the Cleverbridge platform. To do so, use the deleteTextElement mutation object. You must specify the id of the text element you would like to delete.

Example Request

mutation {
  deleteTextElement(id: 1808) {
    deletedTextElementId
  }
}

The API call returns the deleteTextElement object with the requested fields.

Example Response

{
  "data": {
    "deleteTextElement": {
      "deletedTextElementId": 1808
    }
  }
}

Delete a Product Characteristic

You can use the GraphQL API to delete a product characteristic from the Cleverbridge platform. To do so, use the deleteProductCharacteristic mutation object. You must specify the id of the product characteristic you would like to delete.

Example Request

mutation {
  deleteProductCharacteristic(id: 1714) {
    deletedProductCharacteristicId
  }
}

The API call returns the deleteProductCharacteristic object with the requested fields.

Example Response

{
  "data": {
    "deleteProductCharacteristic": {
      "deletedProductCharacteristicId": 1714
    }
  }
}

Delete a Product Selection

You can use the GraphQL API to delete a product selection from the Cleverbridge platform. To do so, use the deleteProductSelection mutation object. You must specify the id of the product selection you would like to delete.

Example Request

mutation {
  deleteProductSelection(id: 3038) {
    deletedProductSelectionId
  }
}

The API call returns the deleteProductSelection object with the requested fields.

Example Response

{
  "data": {
    "deleteProductSelection": {
      "deletedProductSelectionId": 3038
    }
  }
}

Update a Product Variation

Update a Text Element

To update a text element, use the updateTextElement mutation. You must provide the id of the text element you would like to update and specify the fields you would like to change. The following is an example of an updateTextElement mutation that changes the name and value of the text element from Basic to Standard.

Example Request

mutation {
  updateTextElement(
    input: {
      id: 1807
      name: "Standard"
      baseLanguageId: EN
      texts: [{ value: "Standard", languageId: EN }]
    }
  ) {
    updatedTextElement {
      id
      name
      texts {
        language {
          isoCode
          name
        }
        value
      }
    }
  }
}

The API call returns the updateTextElement object with the requested fields.

Example Response

{
  "data": {
    "updateTextElement": {
      "updatedTextElement": {
        "id": 1807,
        "name": "Standard",
        "texts": [
          {
            "language": {
              "isoCode": "en",
              "name": "English"
            },
            "value": "Standard"
          }
        ]
      }
    }
  }
}

Update a Product Characteristic

To update a product characteristic, use the updateProductCharacteristic mutation. You must provide the id of the product characteristic you would like to update and specify the fields you would like to change. The following is an example of an updateProductCharacteristic mutation that changes the name of an option from Basic to Standard.

Example Request

mutation {
  updateProductCharacteristic(
    input: {
      id: 1714
      name: "Internet Security"
      options: [
        { name: "Standard", textElementId: 1807 }
        { name: "Basic Extended", textElementId: 1809 }
        { name: "Professional", textElementId: 1810 }
        { name: "Enterprise", textElementId: 1811 }
      ]
    }
  ) {
    updatedProductCharacteristic {
      id
      name
      options {
        name
        runningNumber
        textElement {
          id
          name
        }
        productCharacteristic {
          id
          name
        }
      }
    }
  }
}

The API call returns the updateProductCharacteristic object with the requested fields.

Example Response

{
  "data": {
    "updateProductCharacteristic": {
      "updatedProductCharacteristic": {
        "id": 1714,
        "name": "Internet Security",
        "options": [
          {
            "name": "Standard",
            "runningNumber": 1,
            "textElement": {
              "id": 1807,
              "name": "Basic"
            },
            "productCharacteristic": {
              "id": 1714,
              "name": "Internet Security"
            }
          },
          {
            "name": "Basic Extended",
            "runningNumber": 2,
            "textElement": {
              "id": 1809,
              "name": "Basic Extended"
            },
            "productCharacteristic": {
              "id": 1714,
              "name": "Internet Security"
            }
          },
          {
            "name": "Professional",
            "runningNumber": 3,
            "textElement": {
              "id": 1810,
              "name": "Professional"
            },
            "productCharacteristic": {
              "id": 1714,
              "name": "Internet Security"
            }
          },
          {
            "name": "Enterprise",
            "runningNumber": 4,
            "textElement": {
              "id": 1811,
              "name": "Enterprise"
            },
            "productCharacteristic": {
              "id": 1714,
              "name": "Internet Security"
            }
          }
        ]
      }
    }
  }
}

Update a Product Selection

To update a product selection, use the updateProductSelection mutation. You must provide the id of the product selection you would like to update and specify the fields you would like to change. The following is an example of an updateTextElement mutation that adds an item to the product selection.

Example Request

mutation {
  updateProductSelection(
    input: {
      id: 3038
      name: "Version in Cart"
      items: [
        {
          productCharacteristicOptionId: 3962
          productId: 97770
          textElementId: 1807
        }
        {
          productCharacteristicOptionId: 3961
          productId: 97771
          textElementId: 1809
        }
        {
          productCharacteristicOptionId: 3960
          productId: 97772
          textElementId: 1810
        }
        {
          productCharacteristicOptionId: 3959
          productId: 97773
          textElementId: 1811
        }
        {
          productCharacteristicOptionId: 3963
          productId: 97774
          textElementId: 1812
        }
      ]
    }
  ) {
    updatedProductSelection {
      id
      name
      items {
        productCharacteristicOption {
          runningNumber
          name
          productCharacteristic {
            id
            name
          }
        }
      }
    }
  }
}

The API call returns the updateProductSelection object with the requested fields.

Example Response

{
  "data": {
    "updateProductSelection": {
      "updatedProductSelection": {
        "id": 3038,
        "name": "Version in Cart",
        "items": [
          {
            "productCharacteristicOption": {
              "runningNumber": 1,
              "name": "Basic",
              "productCharacteristic": {
                "id": 1182,
                "name": "Version in Cart"
              }
            }
          },
          {
            "productCharacteristicOption": {
              "runningNumber": 2,
              "name": "Basic Extended",
              "productCharacteristic": {
                "id": 1182,
                "name": "Version in Cart"
              }
            }
          },
          {
            "productCharacteristicOption": {
              "runningNumber": 3,
              "name": "Professional",
              "productCharacteristic": {
                "id": 1182,
                "name": "Version in Cart"
              }
            }
          },
          {
            "productCharacteristicOption": {
              "runningNumber": 4,
              "name": "Enterprise",
              "productCharacteristic": {
                "id": 1182,
                "name": "Version in Cart"
              }
            }
          },
          {
            "productCharacteristicOption": {
              "runningNumber": 5,
              "name": "Professional Plus",
              "productCharacteristic": {
                "id": 1182,
                "name": "Version in Cart"
              }
            }
          }
        ]
      }
    }
  }
}