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 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 name | Type | Description | |
|---|---|---|---|
id | string | number | The unique item id |
item_name | string | The display name | |
active | boolean | If false, the whole item will not be returned in any API requests | |
url | string | The item URL | |
image_url | string | The main image URL | |
description | string | The item description | |
keywords | array of strings | A list of keywords to match | |
group_ids | array of strings | The list of item group ids this item relates to | |
metadata | object | array of Metadata | Extended fields. Supports either an object or a list of key-value pairs, as documented below. Values can be JSON. | |
remove | boolean | If 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 name | Type | Description | |
|---|---|---|---|
variation_id | string | number | The unique variation id |
item_id | string | number | The unique item id this variation belongs to |
item_name | string | The variation display name | |
active | boolean | If false, the variation will not be returned in any API requests | |
url | string | The variation URL | |
image_url | string | The variation image URL | |
keywords | array of strings | A list of keywords to match | |
group_ids | array of strings | The list of item group ids this variation relates to | |
metadata | object | array of Metadata | Extended fields. Supports either an object or a list of key-value pairs, as documented below. Values can be JSON. | |
remove | boolean | If 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 name | Type | Description |
|---|---|---|
| string | number | The unique item group id. |
| string | number | The item group id this item group belongs to. |
| array of strings | array of numbers | The item group ids this item group belongs to. |
| string | The display name. |
| object | An object to store any custom data. |
| boolean | If 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.
A note onparent_idsFields
parent_idsandparent_idare mutually exclusive and should not be present in the template simultaneously. When usingparent_idsmake sure to also inject the root group with idallto preserve the hierarchy.
Metadata
Both items and variations can ingest Metadata to define extended fields.
Metadata can be defined in two ways - either as an object or an array of key-value pairs.
Object metadata
The simplest use case is to define your metadata in a single object. In this case, the fields are parsed as the keys and values as values.
Here's an example on how to define your metadata in an object:
{
"metadata": {
"allergens": "gluten",
"rating": 4.99,
"reviews": [
{
"author": "John Doe",
"rating": 5,
"comment": "Great!"
},
{
"author": "Jane Doe",
"rating": 4,
"comment": "Good!"
}
]
}
}Key-value pair metadata
For more specific use cases, you can shape metadata in a key-value pair array. Note that with this approach, you can force fields to be parsed into JSON with the json flag. You must follow this structure:
| Field name | Type | Description | |||
|---|---|---|---|---|---|
key | string | The metadata key | |||
value | string | number | object | array of strings, numbers or objects | The metadata value |
json | boolean | If true, it'll force the field to be ingested as a JSON regardless of the value. |
Here's an example on how to define your metadata in a key-value pair:
{
"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!"
}
]
}
]
}
A note on facetsFacets are no longer defined in a catalog file. Instead, you should ingest this data as metadata and configure it as facetable via the Constructor dashboard or our API.
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.mdfile within your Connect CLI repository for more details and examples on developingitem,variations, anditem groupstemplates.
Updated 12 days ago