# ProductAttributeAssignment

## Description

ProductAttributeAssignment records the assignment of a single attribute value to a specific product. A product can have multiple assignments for the same attribute, each carrying a different value (e.g., Color=Red, Color=Blue, Color=Green). All assignments participate in variant generation — the set of values per attribute defines the variant axes.

This model is the junction between Product and ProductAttribute, carrying the actual attribute values for each product.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [assignAttributeValueToProduct](../command/AssignAttributeValueToProduct.md) - Assign an attribute value to a product
- [removeAttributeValueFromProduct](../command/RemoveAttributeValueFromProduct.md) - Remove an attribute value from a product

### Query Definitions

- GetProductAttributeAssignment - Retrieve a specific assignment by productId and attributeId
- ListProductAttributeAssignments - Retrieve all attribute assignments for a given product

### Models

- ProductAttributeAssignment

### Invariants

- Each record references a valid Product and a valid ProductAttribute
- The combination of (productId, attributeId, valueId) must be unique — multiple values per attribute are allowed
- The value must reference a valid ProductAttributeValue belonging to the attribute
- On DRAFT products: assignments can be freely created and removed
- On ACTIVE products: adding new values to an already-assigned attribute is allowed (additive-only); removing existing values or assigning a new attribute is blocked
- On ARCHIVED products: all assignment changes are blocked

### Relationships

- **Belongs To Product**: Each record is associated with exactly one product
- **Belongs To ProductAttribute**: Each record references exactly one attribute definition
- **References ProductAttributeValue**: The value references a predefined option
