Managing Categories
Categories organize your products into a hierarchy. Entaprenua uses PostgreSQL's LTree extension for efficient tree queries — categories can nest to any depth.
Category Structure
Each category has:
| Field | Description |
|---|---|
| Name | Display name |
| Slug | URL-friendly identifier |
| Image | Optional category image |
| Parent | Parent category (null for root categories) |
| Path | LTree path (e.g., 1.2.3 — read-only, managed automatically) |
| Level | Depth in the tree (1 = root, computed from path) |
| Visibility | public, private, or draft |
Creating Categories
- Go to Admin → Categories
- Click New Category
- Fill in the name and optional slug
- Choose a parent category (or leave empty for root)
- Set visibility
- Save
Categories use the same upsert pattern as products — include an id to update an existing category.
Viewing Categories
The category list supports multiple views:
| Query | What it returns |
|---|---|
| Default (no params) | All categories for the store |
?tree=true |
Full nested category tree in a single request |
?root=true |
Root categories only (parentId is null) |
?parentId={id} |
Categories below a specific parent, with isMappedToParent flag |
Tree View
?tree=true returns the entire hierarchy in one API call. The storefront CategoryTree component uses this for fast rendering:
<CategoryTree>
<CategoryTreeView>
<Category>
<CategoryName />
<CategoryTreeSubcategories>
{/* Automatically recursive */}
</CategoryTreeSubcategories>
</Category>
</CategoryTreeView>
</CategoryTree>
Checkbox UI (Product Mapping)
?parentId={id} returns all categories at levels below the parent. Each category includes an isMappedToParent flag — true if it's a direct child of the specified parent. This enables checkbox-based UI for assigning parent categories.
Category Depth Control
The storefront CategoryList component supports depth-controlled recursion:
<CategoryList maxDepth={3}>
<CategoryListView>
<Category>
<CategoryName />
<SubcategoryList>
{/* Auto-fetches children, stops at maxDepth */}
</SubcategoryList>
</Category>
</CategoryListView>
</CategoryList>
At maxDepth (default: 3), SubcategoryList stops rendering — no infinite recursion.
Deleting Categories
- Go to Admin → Categories
- Open the category's menu
- Click Delete
Deleting a category does not delete its products — they become uncategorized. Child categories are not deleted automatically; reassign them first.
Category Storefront Components
| Component | Use Case |
|---|---|
CategoryList |
Display root categories with depth control |
CategoryTree |
Full tree in single API call (faster for static trees) |
SubcategoryList |
Auto-fetch children within a Category |
Category (root) |
Single category by slug from URL |
CategoryName, CategoryImage, etc. |
Atomic display sections |