Grouping template
After transforming variations, you have the option to run them through a grouping flow before ingestion happens. This is done using a grouping template, and can help in scenarios like "exploding" variations into items following a specific criteria (for example, color, pattern, etc.). You can define these scenarios with your own custom logic inside the template.
The purpose of a grouping template is to take in variation data and return an item. It converts a variation itself into an item (and thus moves it up one level in the hierarchy). These variations-as-items can hold their own set of variations depending on the logic you specify in your template.
Keep in mind that any duplicated items returned by the grouping template will be discarded. The template will use the first valid item in the transformation order and discard any other items with the same id
generated by the following transformations.
Do I need a grouping template?
A grouping template is completely optional. You only need to develop one if you find yourself in a scenario where you need to group your variations into the item level during the ingestion phase. A grouping template will entirely change your catalog before it reaches Constructor.
A grouping template alternative
The alternative to using the grouping template is to use variation slicing when you make requests to our API. Variation slicing logic runs in request time, whereas grouping template runs in ingestion time.
The difference between the two is whether you wish to group your variations on the catalog level or during request time, such as a search or browse request. There are key differences between both approaches such as query performance, impacts on Searchandising and more.
Please reach out to our Customer Success team in case you have any questions on which approach to take should you need to group your variations.
Grouping template use cases
Below are two common scenarios where a retailer might choose to use a grouping template:
1. Grouping variations by color
Say you have a clothing store and you store a specific item in the following structure:
Level | Title | Color | Size |
---|---|---|---|
Item | Stretch Oxford Shirt | - | - |
Variation | Stretch Oxford Shirt (Wild Rose) | Wild Rose | Medium |
Variation | Stretch Oxford Shirt (Wild Rose) | Wild Rose | Large |
Variation | Stretch Oxford Shirt (Regal Purple) | Regal Purple | Medium |
Variation | Stretch Oxford Shirt (Regal Purple) | Regal Purple | Large |
Note that an item contains variations that change either in color and size. Normally, when making requests to Constructor, this item would be displayed in one tile as it is one item that contains four variations.
However, you can use the grouping template to group variations by color which would display two tiles, one per color.
2. Grouping variations by initial letter
Say you have a jewelry store and you store a specific item in the following structure:
Level | Title | Initial Letter |
---|---|---|
Item | Initial Pendant in 10kt Yellow Gold | - |
Variation | "A" Initial Pendant in 10kt Yellow Gold | A |
Variation | "B" Initial Pendant in 10kt Yellow Gold | B |
Note that an item contains variations that change in their initial letter. Normally, when making requests to Constructor, this item would be displayed in one tile since it is one item that contains two variations.
However, you can use the grouping template to group variations by initial letter which would display two tiles, one per letter.
How do I develop a grouping template?
Prerequisites
To develop a grouping template, you will need:
- A variation template: Variations must will need to have been transformed via a variation template before they can be grouped.
- A variation fixture: A variation fixture is used when executing and testing grouping templates.
Develop your grouping template
Follow the development flow to develop and test a grouping template.
Note that the connector will pipe the variation data through the grouping template. This means that you need a variation template already developed to define your variation transformations, as well as a variation fixture.
When developing your grouping template, you will first identify the grouping logic you wish to apply to your variations. As stated preceding, this could be by color, initial letter, or any other attribute you have (or can compute) in your catalog.
Once you are happy with how your grouping template looks, you can execute it and create automated tests to ensure it works properly. Finally, when you are satisfied with your template, you can deploy it.
Data structure
A grouping template should return an item, so it should follow the same data structure from the item template. Note that duplicate items by id
will be discarded.
Need more information on developing a grouping template?
Please refer to the
README.md
file within your Connect CLI repository for more details and examples on developing a grouping template.
Updated about 2 months ago