# generateVariants

## Overview

Generates product variants from the cartesian product of all assigned attribute values. Each variant creates a linked Item using the configured SKU strategy. Generated items have their barcode set to the SKU value and are automatically activated so they are immediately usable in purchasing and inventory.

The operation is idempotent — existing attribute value combinations are skipped.

## Modules Commands Used

- [product-management] GenerateVariants
- [item-management] UpdateItem (sets barcode = SKU for each generated item)
- [item-management] ActivateItem (for each generated item)

## Exception Handling

| Error Code | Description |
| --- | --- |
| PRODUCT_MANAGEMENT_PRODUCT_NOT_FOUND | The specified product does not exist |
| PRODUCT_MANAGEMENT_INVALID_PRODUCT_STATUS | Product is not in ACTIVE status |
| PRODUCT_MANAGEMENT_NO_VARIANT_AXES | No attribute values are assigned to the product |
| PRODUCT_MANAGEMENT_ITEM_CREATION_FAILED | Item creation failed during variant generation |
| ITEM_MANAGEMENT_DUPLICATE_BARCODE | Barcode (SKU) already exists on another item |
| ITEM_MANAGEMENT_ITEM_NOT_FOUND | Generated item not found during barcode update or activation |
| ITEM_MANAGEMENT_INVALID_STATE_TRANSITION | Generated item is not in a valid state for activation |
