Category schema for product organization.
Supports hierarchical nesting via parent_id.
Fields
name- Category name (required)slug- URL-friendly identifier (unique)description- Category descriptionfeatured_product_id- Featured product for fallback imageparent_id- Parent category for nestingposition- Sort orderstatus- Category status: "active", "hidden", "archived"metadata- JSONB for custom fieldsoption_schema- Category-specific product option definitions (JSONB array)
Status Values
active- Category and products visible in storefrontunlisted- Category hidden from menu, but products still visiblehidden- Category and all products hidden from storefront
Summary
Functions
Returns true if category is active (visible in storefront).
Returns the full path of category names from root to this category. Requires parent to be preloaded.
Changeset for category creation and updates.
Returns the image URL for a category.
Returns true if category has children.
Returns true if category is hidden (category and products not visible).
Returns the list of localized field names.
Returns true if products in this category should be visible in storefront. Products are visible when category is active or unlisted.
Returns true if category is a root category (no parent).
Returns true if category should appear in category menu/list. Only active categories appear in the menu.
Returns list of valid category statuses
Returns true if category is unlisted (not in menu, but products visible).
Types
@type t() :: %PhoenixKit.Modules.Shop.Category{ __meta__: term(), children: term(), description: term(), featured_product: term(), featured_product_id: term(), featured_product_uuid: term(), id: term(), image_id: term(), inserted_at: term(), metadata: term(), name: term(), option_schema: term(), parent: term(), parent_id: term(), parent_uuid: term(), position: term(), products: term(), slug: term(), status: term(), updated_at: term(), uuid: term() }
Functions
Returns true if category is active (visible in storefront).
Returns the full path of category names from root to this category. Requires parent to be preloaded.
Parameters
category- Category struct with parent preloadedlanguage- Language code for localized names (default: system default)
Examples
iex> breadcrumb_path(category, "en")
["Home", "Electronics", "Phones"]
Changeset for category creation and updates.
Returns the image URL for a category.
Priority:
- Storage media (image_id) if available
- Featured product's featured_image_id (requires :featured_product preloaded)
- Featured product's legacy featured_image URL (requires :featured_product preloaded)
- nil if no image
Options
:size- Storage dimension to use (default: "large")
Returns true if category has children.
Returns the list of localized field names.
Returns true if products in this category should be visible in storefront. Products are visible when category is active or unlisted.
Returns true if category is a root category (no parent).
Returns list of valid category statuses
Returns true if category is unlisted (not in menu, but products visible).