Close
logo

Variant Transformation

Git RepositoryEdit on Github
Last update: 8 months ago by Francesco de LorenziReading time: 2 min

When publishing variants from an inventory feed to a channel, Jetti makes it possible to configure some variant transformations (e.g. adding/remove tags) directly from Jetti's app. However, it may be necessary to perform more advancd transformations such as content translation, description formatting and potentially any sort of manipulation of the product properties.

This can be carried out by instructing Jetti to send the variant object to a remote endpoint, which would need to return the transformed variant.

The feature is accessible from Inventory -> Inventory Feeds -> Feed Name -> Settings -> Publishing.

From that page, it will be possible to enable the Use parse webhook endpoint flag and enter the endpoint URL.

Jetti will send a PUT request to the endpoint with a payload corresponding to the Variant object. Further information about the Variant object is available via Jetti's API Reference.

As a response, the endpoint can pass the original JSON object with changed values or just a subset of the original object.

In order to kickstart the Variant Transformation endpoint development, Jetti offers a sample NodeJS script src/server.js available in the jetti.integrations GitHub repository.

The script exposes multiple HTTP endpoints among which there is a sample PUT /transform.json as seen in the code snippet below:

// Transforms an inventory feed item for publishing
app.put('/transform.json', (req, res) => {
logger.info('Received inventory feed variant', req.body);
const transformed = {
productType: 'top',
images: ['https://transform.com?url=https://images.com/short.png'],
tags: ['custom_blue', 'custom_large', 'custom_t-shirt'],
options: [{
name: 'Color',
value: 'Blue',
position: 1,
}, {
name: 'Size',
value: 'Lg',
position: 2,
}],
};
logger.info('Returning transformed data', { transformed });
return res.json({ transformed });
});

In this particular example, a subset of the original Variant object is returned.

πŸ” Recipes β€” Previous
Querying by External IDs
Next