Transformation templates

Constructor connectors leverage transformation templates to allow you to customize how your data is ingested. While partner connectors provide a base layer of transformation, the Omni Connector relies on you to specify how the data is transformed.

There are three types of transformation templates:

  • Item: Allows you to customize how your Constructor items are transformed.
  • Variation: Allows you to customize how your Constructor variations are transformed.
  • Item Group: Allows you to customize how your Constructor item groups are transformed.

Keep in mind that fixtures stored in the repository represent the data that flows through a connector in a live integration. It will always follow the same structure, so you can refer to a fixture to see how to reach for the pieces of data you want to use.

Each transformation template is expected to return an object with the data that should be ingested. This data mostly follows the CSV Feed Format for items, variations, and item groups, but note that templates might provide additional fields to expose connector features.

The Connect CLI Data Transformation Process

The data transformation process

Data structure

As mentioned preceding, each template is expected to return a specific set of fields to be ingested.

Note that in templates, fields are optional. For the case of partner connectors, not returning a field means you will not override what the connector is doing, and for the Omni Connector, not returning a field means that Constructor will not ingest it.

Please note that not returning a required field (for example, id) might cause your ingestion to fail.

Item template

The item template is expected to return an object containing the following fields:

Field nameTypeDescription
idstringThe unique item id
item_namestringThe display name
activebooleanIf false, the whole item will not be returned in any API requests
urlstringThe item URL
image_urlstringThe main image URL
descriptionstringThe item description
keywordsstring arrayA list of keywords to match
group_idsstring arrayThe list of item group ids this item relates to
metadatakey-value pair arrayA list of metadata in a key-value pair format. Values can be JSON
facetskey-value pair arrayA list of facets in a key-value pair format

⚠️ warning: this is deprecated and will be removed. please ingest the data with metadata instead.
removebooleanIf true, this record will be removed from the ingestion, thus not being indexed in Constructor.

Variation template

The variation template is expected to return an object containing the following fields:

Field nameTypeDescription
variation_idstringThe unique variation id
item_idstringThe unique item id this variation belongs to
item_namestringThe variation display name
activebooleanIf false, the variation will not be returned in any API requests
urlstringThe variation URL
image_urlstringThe variation image URL
keywordsstring arrayA list of keywords to match
metadatakey-value pair arrayA list of metadata in a key-value pair format. Values can be JSON
facetskey-value pair arrayA list of facets in a key-value pair format

⚠️ warning: this is deprecated and will be removed. please ingest the data with metadata instead.
removebooleanIf true, this record will be removed from the ingestion, thus not being indexed in Constructor.

Item group template

The item group template is expected to return an object containing the following fields:

Field nameTypeDescription
idstringThe unique item group id
namestringThe display name
parent_idstringThe item group id this item group belongs to
dataobjectAn object to store any custom data
removebooleanIf true, this record will be removed from the ingestion, thus not being indexed in Constructor.

Note that any JSON data can be ingested into the item group data field, similarly to how metadata works with JSON.

Facets

❗️

Deprecation notice

Configuring facets via catalog ingestions is deprecated. If you choose to ingest a field using facets on your template it won't be automatically configured.

Instead, you should ingest the data as metadata and configure it to be facetable via the customer dashboard or API.

Both items and variations can ingest the same facets array. It is data shaped in a key-value pair that will be ingested into your Facets. Here is how each object should look inside the key-value pair array:

Field nameTypeDescription
keystringThe facet key
valuestring | number | string array | number arrayThe facet value

Keep in mind that facets should have primitive values or an array of primitive values. This means you cannot store JSON or complex data within a facet.

Here is an example of valid facet values:

{
  "facets": [
    {
      "key": "stock",
      "value": 42
    },
    {
      "key": "color",
      "value": "green"
    },
    {
      "key": "prices",
      "value": [10, 20, 30]
    }
  ]
}

Metadata

Both items and variations can ingest the same metadata array. It is data shaped in a key-value pair that will be ingested into your Metadata. Here is how each object should look inside the key-value pair array:

Field nameTypeDescription
keystringThe metadata key
valuestring | number | string array | number array | object | object arrayThe metadata value
jsonbooleanIf true, it'll force the field to be ingested as a JSON regardless of the value.

Unlike facets, metadata fields can hold JSON data. To achieve this, specify a JSON piece of data in the value and it will be ingested and returned as JSON during API calls.

Here is an example of valid metadata values:

{
  "metadata": [
    {
      "key": "allergens",
      "value": "gluten"
    },
    {
      "key": "rating",
      "value": 4.99
    },
    {
      "key": "reviews",
      "value": [
        {
          "author": "John Doe",
          "rating": 5,
          "comment": "Great!"
        },
        {
          "author": "Jane Doe",
          "rating": 4,
          "comment": "Good!"
        }
      ]
    }
  ]
}

How do I create a transformation template?

Prerequisites

To develop transformation templates, you will need:

  • A mapping template: Required if you are using the Omni Connector. This allows you to generate fixtures.
  • Fixtures: Ideally, a fixture for each template type you will develop.

Develop your transformation templates

Follow the development flow to develop and test each transformation template.

Refer to your fixtures to understand the data structure, and write each template according to the tables preceding to map it in a way Constructor can understand. Make sure you also cover any cases for your integration.

Once you are happy with how your template looks, you can execute it and create automated tests to ensure it works properly. Finally, when you are satisfied with all of your templates, you can deploy them.

📘

Need more information on developing transformation templates?

Please refer to the README.md file within your Connect CLI repository for more details and examples on developing item, variations, and item groups templates.


What’s Next