# Product Category

## Overview

Product categories provide a hierarchical tree structure for classifying products. Each category is identified by a unique code and has a display name. Categories organize the commercial/marketing view of products (e.g., Apparel > Men's > T-Shirts). Products can belong to multiple categories (many-to-many), enabling multi-dimensional classification. This is distinct from item-management's taxonomy, which classifies Items at the SKU level.

## Business Purpose

Product categories serve the commercial organization of product lines:

- Marketing teams organize products into browsable hierarchies for catalogs, e-commerce navigation, and reporting
- Multiple category trees can coexist (e.g., one by product type, another by season or collection)
- Categories at the product level group related products (and their variants) together, while item-management's taxonomy classifies individual SKUs for operational purposes

The separation from item taxonomy ensures:

- Product teams can reorganize commercial categories without affecting operational item classification
- A product (e.g., "Classic T-Shirt") belongs to a marketing category, while its individual Items (SKUs) may have separate taxonomy assignments for warehouse or procurement purposes

## Process Flow

```mermaid
flowchart TD
    A[Create Root Category] --> B[Create Child Categories]
    B --> C[Build category tree]
    C --> D[Assign products to categories]
    D --> E{Product in multiple categories?}
    E -->|Yes| F[Create additional assignments]
    E -->|No| G[Single assignment]
```

Example category tree structure:

```mermaid
flowchart TD
    R[Root: All Products] --> A[Apparel]
    R --> B[Accessories]
    A --> C[Men's]
    A --> D[Women's]
    C --> E[T-Shirts]
    C --> F[Pants]
    D --> G[Dresses]
    B --> H[Bags]
    B --> I[Jewelry]
```

## Scenario Patterns

- **Category Tree Setup**: A root category "All Products" is created, then child categories are added hierarchically (Apparel > Men's > T-Shirts)
- **Multi-Category Assignment**: A "Unisex T-Shirt" product is assigned to both "Men's > T-Shirts" and "Women's > T-Shirts" categories
- **Category Reorganization**: A category is moved from one parent to another (e.g., "Accessories" moved under "Apparel")
- **Category Deletion**: A leaf category with no product assignments is deleted. Categories with assignments or children cannot be deleted
- **Depth Limit**: Category tree depth is configurable (default max depth enforced to prevent excessively deep hierarchies)

## Test Cases

- Categories require a unique code (globally unique) and a display name
- Category code is immutable after creation
- Root categories have no parent
- Child categories reference a valid parent category
- Category tree respects a configurable maximum depth
- Circular references are prevented (a category cannot be its own ancestor)
- Products can be assigned to multiple categories (many-to-many)
- Category deletion is blocked if the category has child categories or product assignments
- Moving a category updates all descendant paths
- Category names can be updated without affecting product assignments

## Reference Links

- [Odoo Product Categories](https://www.odoo.com/documentation/19.0/applications/inventory_and_mrp/inventory/product_management.html)
- [Akeneo Category Trees](https://help.akeneo.com/pim/serenity/articles/what-about-products-variants.html)
