VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/2.3-configuration-system-overview

⇱ Configuration System Overview | MahoCommerce/maho | DeepWiki


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

Configuration System Overview

Maho's configuration system manages application settings through a hierarchical structure that merges data from XML files, PHP attributes, and the database. This architecture supports complex multi-store deployments by allowing settings to cascade from global defaults down to specific store view overrides.

Purpose and Organization

The configuration system serves as the central registry for all application settings, module declarations, and class mappings. It provides a unified API to retrieve values while handling the complexity of scope inheritance and performance caching.

Key characteristics:

Sources: app/code/core/Mage/Core/Model/Config.php15-281 lib/Maho/Config/Observer.php13-46

Configuration Scopes

Configuration values exist in a three-tier hierarchy. More specific scopes inherit from and can override less specific ones.

Scope Hierarchy

Title: Configuration Inheritance Flow































ScopeXML Path PatternDatabase TableUse Case
Defaultdefault/section/group/fieldcore_config_dataGlobal settings used if no override exists.
Websitewebsites/{code}/...core_config_dataSettings shared by all store views in a website.
Storestores/{code}/...core_config_dataStore-specific settings (e.g., Locale, Theme).

Sources: app/code/core/Mage/Core/Model/Config.php89-95 app/Mage.php277-280

Configuration Sources and Loading

The configuration tree is assembled during the application bootstrap process. The Mage_Core_Model_Config class manages the loading sequence.

Loading Sequence

Title: Configuration Initialization Lifecycle


Source Details

  1. Base Configuration: Loads the fundamental system settings from app/etc/ including database credentials in local.xml. app/code/core/Mage/Core/Model/Config.php277-279
  2. Module Configuration: Iterates through all active modules and merges their etc/config.xml. This defines models, blocks, helpers, and default values. app/code/core/Mage/Core/Model/Config.php15-71
  3. Compiled Attributes: Maho uses PHP Attributes for event observers. These are compiled during composer dump-autoload and merged into the configuration tree. For example, #[Maho\Config\Observer] is used to register observers lib/Maho/Config/Observer.php20-22 Examples include Mage_CatalogInventory_Model_Observer::addInventoryData app/code/core/Mage/CatalogInventory/Model/Observer.php44 Mage_GiftMessage_Model_Observer::salesEventConvertQuoteItemToOrderItem app/code/core/Mage/GiftMessage/Model/Observer.php20-21 Mage_Tag_Model_Tag::productEventAggregate app/code/core/Mage/Tag/Model/Tag.php194-195 Mage_Weee_Model_Observer::setWeeeRendererInForm app/code/core/Mage/Weee/Model/Observer.php20 Maho_AdminActivityLog_Model_Observer::logAdminLogin app/code/core/Maho/AdminActivityLog/Model/Observer.php48 and Mage_Catalog_Model_Product_Compare_Item::bindCustomerLogin app/code/core/Mage/Catalog/Model/Product/Compare/Item.php165
  4. Database Overrides: Values from the core_config_data table are merged into the tree via the Resource Model. app/code/core/Mage/Core/Model/Config.php232-240
  5. Environment Variables: Configuration values can also be overridden by environment variables prefixed with MAHO_CONFIG__. This allows for dynamic configuration based on deployment environment. The Mage_Core_Helper_EnvironmentConfigLoader helper processes these variables. app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php11-17

Sources: app/code/core/Mage/Core/Model/Config.php15-280 app/code/core/Mage/Core/Model/App.php255-261 lib/Maho/Config/Observer.php13-46 app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php11-17

Accessing Configuration

Developers primarily interact with configuration through the Mage static class or by accessing the configuration tree directly via the config model.

Code Entity Mapping

Title: Configuration Access Pattern


Common Access Components

ComponentPathDescription
Mage::getStoreConfig()app/Mage.php277-280High-level API to retrieve scoped configuration values for a specific store.
Mage::getConfig()->getNode()app/code/core/Mage/Core/Model/Config.php281-282Accesses the raw merged XML tree as a Maho\Simplexml\Element.
Mage_Core_Model_Configapp/code/core/Mage/Core/Model/Config.php13-14The primary class responsible for managing the application configuration state.
Maho\Config\Observerlib/Maho/Config/Observer.php27-28Attribute used to register event observers directly in PHP code.

Sources: app/Mage.php74-280 app/code/core/Mage/Core/Model/Config.php13-282 lib/Maho/Config/Observer.php13-46

Configuration Caching

To optimize performance, Maho caches the merged configuration tree.

Sources: app/code/core/Mage/Core/Model/Config.php73-95

Admin Configuration UI

The "System Configuration" section in the Admin Panel is driven by system.xml files. These files define the UI structure (Tabs, Sections, Groups, Fields) and map them to configuration paths.

Data Flow for Admin Saves

  1. UI Interaction: User modifies a field in Admin > System > Configuration.
  2. Persistence: Values are written to the core_config_data table via the config resource model. app/code/core/Mage/Core/Model/Config.php232-240
  3. Cache Invalidation: The config cache type is cleared (tagged with CONFIG) to ensure the new values are loaded in the next request. app/code/core/Mage/Core/Model/Config.php73

Sources: app/code/core/Mage/Core/Model/Config.php73-240 app/code/core/Mage/Core/Model/App.php255-261