VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/8.2-category-management

⇱ Category Management | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Category Management

This document explains the category management system in Maho's admin interface, focusing on the tree-based UI, drag-and-drop operations, AJAX content updates, and category-product relationships. For product management within categories, see Product Types. For category URL generation and SEO, see URL Rewrites and SEO. For category indexing internals, see Indexing System.

Overview

Categories in Maho use a hierarchical tree structure stored in the EAV system. The admin interface provides a modernized JavaScript-driven tree view using MahoTree public/js/maho-tree.js12 with drag-and-drop reordering, AJAX-based form updates, and integrated product assignment grids. The CategoryEditForm class manages all client-side interactions while maintaining state synchronization with the server public/js/mage/adminhtml/catalog/category.js12

Key Components:

Sources: public/js/maho-tree.js12 public/js/mage/adminhtml/catalog/category.js12 app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php13-14 public/js/mage/adminhtml/catalog/category.js28-83

Category Data Model

Categories use the EAV architecture with additional relationship tables for the tree structure and product associations.

Title: Category Data Architecture


Sources: app/code/core/Mage/Catalog/Model/Resource/Category.php46-55 app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php63-77 app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php110-113

Tree Hierarchy Logic

The hierarchy is maintained using a path field (e.g., 1/2/5) and a position field for ordering. The resource model Mage_Catalog_Model_Resource_Category manages these during the save lifecycle:

Sources: app/code/core/Mage/Catalog/Model/Resource/Category.php157-189 app/code/core/Mage/Catalog/Model/Resource/Category.php198-216 app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php112-168

CategoryEditForm JavaScript Class

The CategoryEditForm class is the central controller for the category management interface. It coordinates the MahoTree, form validation via varienForm, and the product assignment grid.

Title: Category Management Frontend Logic


Sources: public/js/mage/adminhtml/catalog/category.js28-86 public/js/mage/adminhtml/catalog/category.js112-121 public/js/maho-tree.js58-138

Category Tree Operations

Drag-and-Drop Reordering

The UI utilizes MahoTree with sortable options enabled public/js/mage/adminhtml/catalog/category.js68-70 When a move is completed, the moveCategory callback sends the node ID, new parent ID, and the ID of the node it was placed after to the server public/js/mage/adminhtml/catalog/category.js203-228

Sources: public/js/mage/adminhtml/catalog/category.js68-70 public/js/mage/adminhtml/catalog/category.js203-228

UI Options

The Maho admin allows toggling metadata visibility on the tree nodes, such as the Category ID and Product Count public/js/mage/adminhtml/catalog/category.js56-62 These preferences are persisted in localStorage public/js/mage/adminhtml/catalog/category.js94-103

Sources: public/js/mage/adminhtml/catalog/category.js56-62 public/js/mage/adminhtml/catalog/category.js94-103

Category-Product Associations

Products are associated with categories via the catalog_category_product table app/code/core/Mage/Catalog/Model/Resource/Category.php54 In the admin, this is managed by a grid within the category edit page.

Grid Synchronization

The initProductsGrid method in CategoryEditForm synchronizes the selection state of the product grid with a hidden input field public/js/mage/adminhtml/catalog/category.js123-178

Sources: app/code/core/Mage/Catalog/Model/Resource/Category.php54 public/js/mage/adminhtml/catalog/category.js123-178 public/js/mage/adminhtml/catalog/category.js139-148 public/js/mage/adminhtml/catalog/category.js162-174

Flat Catalog (Deprecated)

Maho marks the Flat Catalog Category optimization as deprecated app/code/core/Mage/Catalog/etc/system.xml100 Modern databases (PostgreSQL, SQLite, and optimized MySQL) no longer require the denormalized catalog_category_flat tables for performance app/locale/en_US/Mage_Catalog.csv11 While still present in the codebase for legacy compatibility app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php14-16 it is recommended to use the standard EAV models.

Sources: app/code/core/Mage/Catalog/etc/system.xml100 app/locale/en_US/Mage_Catalog.csv11 app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php14-16

Key Classes and Functions

ClassRoleKey Function
Mage_Catalog_Model_Resource_CategoryResource Model_saveCategoryProducts saves grid associations app/code/core/Mage/Catalog/Model/Resource/Category.php208
Mage_Catalog_Model_Resource_Category_TreeHierarchy ManageraddCollectionData populates tree nodes app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php112
Mage_Adminhtml_Block_Catalog_Category_AbstractBlock BasegetRoot initializes the tree root based on store context app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php149
CategoryEditForm (JS)Admin ControllersubmitCategory handles AJAX form submission public/js/mage/adminhtml/catalog/category.js230
MahoTree (JS)UI ComponentsetRootNode renders the interactive tree public/js/maho-tree.js140

Sources: app/code/core/Mage/Catalog/Model/Resource/Category.php208 app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php112 app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php149 public/js/mage/adminhtml/catalog/category.js230 public/js/maho-tree.js140