VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/14-api-reference

⇱ API Reference | MahoCommerce/maho | DeepWiki


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

API Reference

This section provides comprehensive API documentation for Maho's core classes and methods that developers use to interact with the system. It covers the public interfaces for configuration access, object instantiation, data retrieval, and system interaction.

For information about creating custom extensions, see Extension Development. For architectural patterns and system design, see Core Architecture.

Overview

Maho's API is organized into several layers, each providing specific functionality:

API LayerPrimary ClassesPurpose
Static HubMageFactory methods, registry, global utilities app/Mage.php18
ConfigurationMage_Core_Model_ConfigXML config access, store-scoped settings app/code/core/Mage/Core/Model/Config.php13
Data ModelsMage_Core_Model_AbstractBusiness logic, data persistence app/code/core/Mage/Tag/Model/Tag.php38
Web API (REST)Mage_Api2_Model_ResourceAbstract resource for RESTful API interactions app/code/core/Mage/Api2/Model/Resource.php27
LayoutsMage_Core_Model_LayoutManagement of blocks and layout XML app/code/core/Mage/Core/Model/Layout.php13
HelpersMage_Core_Helper_AbstractUtility functions, formatting, translation app/code/core/Mage/Payment/Helper/Data.php13
ApplicationMage_Core_Model_AppApplication lifecycle, store/area management app/Mage.php71

Sources: app/Mage.php18-19 app/code/core/Mage/Core/Model/Config.php13-14 app/code/core/Mage/Tag/Model/Tag.php38-39 app/code/core/Mage/Api2/Model/Resource.php27-28 app/code/core/Mage/Core/Model/Layout.php13-14 app/code/core/Mage/Payment/Helper/Data.php13-14

Core API Patterns

Factory Pattern and Object Instantiation

The factory pattern is the primary way to instantiate objects in Maho, allowing for class rewrites and singleton management via the global registry.

Natural Language to Code Entity Space: Factory Resolution


Sources: app/Mage.php57-58 app/code/core/Mage/Core/Model/Config.php114-127

Event-Driven API (Observers)

Maho uses a sophisticated event system where observers can be registered via XML or modern PHP Attributes. The Maho\Config\Observer attribute allows defining the event, area, and instantiation type directly in the class method.

Natural Language to Code Entity Space: Event Dispatch


Sources: app/code/core/Mage/CatalogInventory/Model/Observer.php121-122 app/code/core/Maho/AdminActivityLog/Model/Observer.php133-134 app/code/core/Mage/GiftMessage/Model/Observer.php20-21 app/code/core/Mage/Tag/Model/Tag.php194-196

Mage Static Class API

The Mage class is the central hub for the application. It is a final class containing only static methods and properties.

Key Static Methods

MethodReturn TypePurpose
getVersion()stringReturns current version (e.g., '26.5.0') app/Mage.php118-121
getStoreConfig($path)mixedRetrieves configuration value for current store app/Mage.php277-280
register($key, $value)voidAdds variable to global registry app/Mage.php147-156
registry($key)mixedRetrieves variable from global registry app/Mage.php179-182
unregister($key)voidRemoves variable from registry app/Mage.php163-171
getBaseDir($type)stringReturns absolute path for directory types app/Mage.php253-256
objects($key)\Maho\DataObject\CacheAccesses the internal object cache app/Mage.php236-245
app()Mage_Core_Model_AppReturns the application model instance app/Mage.php71

For details, see Mage Static Class.

Sources: app/Mage.php118-121 app/Mage.php147-182 app/Mage.php236-256 app/Mage.php277-280

Configuration API

The configuration system manages XML merging from config.xml, local.xml, and the core_config_data database table.

Configuration Hierarchy

  1. Mage_Core_Model_Config_Base: Basic XML loading and XPath access.
  2. Mage_Core_Model_Config: Core logic for merging modules, DB settings, and cache management app/code/core/Mage/Core/Model/Config.php13-14

Common Methods

For details, see Configuration API.

Sources: app/code/core/Mage/Core/Model/Config.php13-14 app/code/core/Mage/Core/Model/Config.php234-240 app/code/core/Mage/Core/Model/Config.php247-250 app/code/core/Mage/Core/Model/Config.php272-274

Block and Layout API

Blocks are responsible for rendering HTML via templates. They interact with the Mage_Core_Model_Layout object to manage child relationships and output.

Layout Management

Block Lifecycle

  • _construct(): Internal constructor for block initialization.
  • _prepareLayout(): Hook for layout-related setup.

For details, see Block API and Layout and Template API.

Sources: app/code/core/Mage/Core/Model/Layout.php135-223

Database and Model API

Maho uses a separation between Models (Business Logic) and Resource Models (SQL Logic).

Model Operations

For details, see Database Adapter Interface.

Sources: app/code/core/Mage/Tag/Model/Tag.php38-91 app/code/core/Mage/Core/Model/App/Area.php13-17

REST API (API2)

Maho provides a RESTful API framework via the Mage_Api2 module.

Core Components

Sources: app/code/core/Mage/Api2/Model/Server.php13-14 app/code/core/Mage/Api2/Model/Resource.php27-41 app/code/core/Mage/Api2/Model/Resource.php180-182

Helper API

Helpers provide utility functions for common tasks like formatting, translation, and HTML escaping.

Common Helper Methods

  • __(): The standard translation function provided by Mage_Core_Helper_Abstract.
  • escapeHtml($data): Securely escapes HTML entities.
  • getMethodInstance($code): Specific helper method in Mage_Payment_Helper_Data to instantiate payment methods app/code/core/Mage/Payment/Helper/Data.php38-46

For details, see Helper Classes.

Sources: app/code/core/Mage/Payment/Helper/Data.php38-46

Child Pages Reference

PageDescription
Mage Static ClassReference for Mage:: static methods, factory pattern, and global functions.
Configuration APIReference for Mage_Core_Model_Config methods, getStoreConfig, and XML node access.
Block APIReference for Mage_Core_Block_Abstract, rendering lifecycle, and caching methods.
Helper ClassesReference for Mage_Core_Helper_Data and common helper patterns.
Database Adapter InterfaceReference for database abstraction, query building, and transaction handling.
Layout and Template APIReference for layout XML syntax, block methods, and template variables.
Email Template DirectivesReference for email template syntax, variables, and directive parsing.

Sources: app/Mage.php app/code/core/Mage/Core/Model/Config.php app/code/core/Mage/Core/Model/Layout.php app/code/core/Mage/Api2/Model/Resource.php