> ## Documentation Index
> Fetch the complete documentation index at: https://afrizon-admin.tunzaa.co.tz/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and manage product categories in Meneja

> Build flat or hierarchical product categories, assign them to products, and control which categories are visible on your storefront with the active toggle.

Categories in Meneja give you a way to organize products so that shoppers can browse and find what they need on the storefront. You can create a flat list of categories or build a multi-level hierarchy by assigning a `parent_id` to any category — making it a subcategory of another. Each category also has an `is_active` toggle that controls whether it appears on the storefront without requiring you to delete it.

## Category fields

Each category record contains the following fields:

| Field           | Type                | Description                                                                                |
| --------------- | ------------------- | ------------------------------------------------------------------------------------------ |
| `name`          | string              | Display name of the category (minimum 2 characters)                                        |
| `slug`          | string              | URL-friendly identifier (e.g. `"mens-clothing"`); auto-generated from `name` if left blank |
| `description`   | string *(optional)* | Short description shown on the category page                                               |
| `parent_id`     | string *(optional)* | ID of another category that acts as the parent; enables nested categories                  |
| `image_url`     | string *(optional)* | URL of an image representing the category                                                  |
| `is_active`     | boolean             | Controls storefront visibility; `true` means the category is live                          |
| `display_order` | number              | Controls the sort order of categories in lists                                             |

<Info>
  The `slug` is automatically derived from the `name` when you create a category and leave the slug field blank. If you edit the slug manually, the auto-generation stops for that session so your custom value is preserved.
</Info>

## Hierarchical categories with `parent_id`

Setting `parent_id` on a category makes it a child of another category. This lets you build multi-level category trees — for example:

* **Electronics** (top-level, `parent_id` is empty)
  * **Phones** (`parent_id` = Electronics)
  * **Laptops** (`parent_id` = Electronics)

There is no hard limit on nesting depth, but keep hierarchies shallow enough for shoppers to navigate comfortably. A category cannot be set as its own parent.

<Note>
  In the category table, the **Parent Category** column resolves the `parent_id` to its display name automatically. If the parent category is deleted or unavailable, the column shows a dash.
</Note>

## Creating a category

<Steps>
  <Step title="Open the Categories page">
    Navigate to **Categories** in the sidebar. Click **New Category** (or the equivalent create button) to open the category form.
  </Step>

  <Step title="Fill in the required fields">
    Enter a **Name** (required, minimum 2 characters) and a **Slug** (required, minimum 2 characters). The slug auto-populates as you type the name — you can leave it as-is or customize it.
  </Step>

  <Step title="Add optional details">
    Optionally add a **Description**, select a **Parent Category** from the dropdown to nest this category under another, and upload an **Image** to represent the category visually.
  </Step>

  <Step title="Set the active state">
    Use the **Active** toggle to control whether the category is visible on the storefront immediately. It defaults to active (`true`).
  </Step>

  <Step title="Save the category">
    Submit the form. The new category appears in the category table and is immediately available for assignment to products.
  </Step>
</Steps>

## Editing a category

To edit an existing category, open the row actions menu (the **⋯** icon) next to the category in the table and select **Edit**. The same form used for creation opens pre-filled with the current values. Update any fields and save. The `slug` field is editable — changing it will update the category's URL path on the storefront.

<Warning>
  Changing a category's `slug` after products have been published may affect storefront URLs. Ensure any links or SEO references to the old slug are updated accordingly.
</Warning>

## Toggling a category's active state

You can activate or deactivate a category without deleting it. In the row actions menu, select **Activate** or **Deactivate** depending on the current state. The `is_active` field is updated immediately and the category table reflects the new status with a badge.

| `is_active` value | Badge shown    | Storefront visibility |
| ----------------- | -------------- | --------------------- |
| `true`            | Active (green) | Visible               |
| `false`           | Inactive (red) | Hidden                |

<Tip>
  Use `is_active: false` to temporarily hide a category during seasonal transitions or catalog restructuring without losing the category's configuration or its associated products.
</Tip>

## Deleting a category

To permanently remove a category, open the row actions menu and select **Delete**. A confirmation dialog appears before the deletion is committed. Deleting a category does not automatically remove products assigned to it — products retain their `category_ids` references and must be updated separately if needed.

<Warning>
  Deletion is permanent and cannot be undone. Consider deactivating the category instead if you may need it again in the future.
</Warning>
