# UpdateProductCategory

## Permission Scope

productCatalog

## Overview

updateProductCategory modifies the display name of an existing product category. The category can be looked up by `id` or `code`. In extensible module configurations, consumer-defined custom fields may also be updated through this command. Use moveProductCategory to change the parent.

## Business Rules

- Target category must exist (looked up by `id` or `code`)
- At least one updatable field must be provided
- Name must remain non-empty when provided
- Consumer-defined custom fields may be updated
- Updating name does not affect product assignments or child categories

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Lookup by id or code}
    B -->|Not found| C[Return error: CATEGORY_NOT_FOUND]
    B -->|Found| D{Any updatable fields provided?}
    D -->|No| E[Return error: MISSING_REQUIRED_FIELD]
    D -->|Yes| F[Apply name and/or custom field updates]
    F --> G[Return updated category]
```

## External Dependencies

- None

## Error Scenarios

- **CATEGORY_NOT_FOUND**: Specified category ID does not exist
- **MISSING_REQUIRED_FIELD**: One or more required fields are missing or empty

## Test Cases

- should return CategoryNotFoundError when category does not exist
- should return MissingRequiredFieldError when no fields are provided
- should pass custom fields through to update
- should update category name successfully
- should look up category by code and update name
