![]() |
VOOZH | about |
This document covers the CLI commands for managing admin users and customers in Maho. These commands provide programmatic access to create, modify, list, and delete user accounts without using the web interface.
For information about the overall CLI architecture and command discovery, see CLI Architecture
Maho provides two categories of user management commands:
All commands extend BaseMahoCommand lib/MahoCLI/Commands/BaseMahoCommand.php18-19 and use the Symfony Console framework for input/output handling. Commands are registered in the main CLI entry point maho maho28-42 or discovered via the CommandDiscoverer maho100-104
Command Registration Flow
Title: User Command Registration Architecture
Sources: lib/MahoCLI/Commands/BaseMahoCommand.php13-19 lib/MahoCLI/Commands/AdminUserChangepassword.php13-27 lib/MahoCLI/Commands/CustomerDelete.php13-29 maho28-42
Admin user commands operate on the backend administrator data and interact with the admin/user model. All admin commands require Maho to be initialized in admin mode via initMaho() lib/MahoCLI/Commands/BaseMahoCommand.php20-24
Lists all administrator accounts with their basic information.
Execution Flow:
Title: Admin User List Flow
Sources: lib/MahoCLI/Commands/BaseMahoCommand.php20-24
Changes the password of an existing admin user.
Command Attributes:
Annotated with #[AsCommand(name: 'admin:user:change-password', ...)] lib/MahoCLI/Commands/AdminUserChangepassword.php23-26
Process:
Mage::getModel('admin/user')->loadByUsername($username) lib/MahoCLI/Commands/AdminUserChangepassword.php53-54getUserId() lib/MahoCLI/Commands/AdminUserChangepassword.php55-58setNewPassword($password) lib/MahoCLI/Commands/AdminUserChangepassword.php60save() lib/MahoCLI/Commands/AdminUserChangepassword.php61Sources: lib/MahoCLI/Commands/AdminUserChangepassword.php30-66
These commands toggle the is_active status of an administrator account.
is_active to 1 lib/MahoCLI/Commands/AdminUserEnable.php52-53is_active to 0 lib/MahoCLI/Commands/AdminUserDisable.php52-53Sequence for Status Change:
Title: Admin Status Update Sequence
Sources: lib/MahoCLI/Commands/AdminUserEnable.php30-58 lib/MahoCLI/Commands/AdminUserDisable.php30-58
Customer commands operate on EAV entity tables and interact with Mage_Customer_Model_Customer.
Lists all customers registered in the system.
Implementation Details:
Mage::getResourceModel('customer/customer_collection') to retrieve records lib/MahoCLI/Commands/CustomerList.php34entity_id, website_id, email, firstname, lastname lib/MahoCLI/Commands/CustomerList.php33-35Table lib/MahoCLI/Commands/CustomerList.php41-53Sources: lib/MahoCLI/Commands/CustomerList.php29-56
Deletes customer accounts with support for bulk deletion and email-based lookup lib/MahoCLI/Commands/CustomerDelete.php25-28
Implementation Details:
customer/customer_collection to find matching accounts lib/MahoCLI/Commands/CustomerDelete.php47-49Title: Customer Deletion Logic
Sources: lib/MahoCLI/Commands/CustomerDelete.php31-103
All user management commands share a common architecture based on BaseMahoCommand lib/MahoCLI/Commands/BaseMahoCommand.php18-19
The initMaho() method is critical for CLI operations lib/MahoCLI/Commands/BaseMahoCommand.php20-24:
Mage::register('isSecureArea', true, true): Allows bypass of restricted area checks (e.g., deleting protected entities) lib/MahoCLI/Commands/BaseMahoCommand.php22Mage::app('admin'): Initializes the admin store scope, granting access to administrative models and configurations lib/MahoCLI/Commands/BaseMahoCommand.php23Commands use standard return codes from Symfony\Component\Console\Command\Command:
Command::SUCCESS (0): Task completed successfully lib/MahoCLI/Commands/AdminUserChangepassword.php64Command::FAILURE (1): Logic failure (e.g., user not found) lib/MahoCLI/Commands/AdminUserChangepassword.php57Command::INVALID (2): Input validation failed (e.g., empty password) lib/MahoCLI/Commands/AdminUserChangepassword.php50Sources: lib/MahoCLI/Commands/BaseMahoCommand.php20-24 lib/MahoCLI/Commands/AdminUserChangepassword.php40-64