Product Variants
Product variants are a mechanism used to support different variations of a parent product.
The system is designed to be flexible and to accommodate a wide range of variation types. Variants provide a way to identify and link related products, enabling use cases such as different sizes or colors in a fashion retail scenario.
Although each variant is a distinct SKU, they are logically related through this association. This allows us, for example, to treat different sizes of the same product as essentially the same item when analyzing customer behavior, while still preserving the level of detail required at the SKU level.
In addition, product variants help uncover customer preferences. By analyzing variant-level data, we can identify patterns such as a customer’s preference for a specific color across different product ranges.
These are the relevant properties in the Product object:
| property names | description |
|---|---|
| isVariant | Flag to mark if the product is a variant |
| productParentId | ID of the parent product |
| productVariantOption1Id | ID of first variant option |
| productVariantOption2Id | ID of second variant option |
| productVariantOption3Id | ID of third variant option |
The first requirement is that the parent product is created first, so the productId can be used in the child.
The variant options must be created previously, in the variant controller there are two concepts:
- Variant: Defines a variant concept, following the previous example this would be the size or color.
- VariantOption: Related to the variant, defines all possible values the variant can have e.g. "L, M, S" or "black, red, white"
So, the variant must be created, following with all the variant options related. With this structure in place, the products can be created with the relevant variant information.
