![]() |
VOOZH | about |
This document describes Maho's multi-store architecture, which enables a single Maho installation to serve multiple storefronts with shared or independent catalogs, customer bases, and configurations. This architecture consists of a three-tier hierarchy: Websites, Stores (also called Store Groups), and Store Views.
For information about configuration systems in general, see Configuration System. For details on how products are associated with websites, see Catalog Module.
Maho's multi-store architecture is built on a three-level hierarchy where each level can have different configurations and settings:
Hierarchy Levels:
| Level | Purpose | Code Entity | Key Attributes |
|---|---|---|---|
| Global (Default) | Base configuration for entire installation | Mage_Core_Model_Config | Inherited by all websites/stores |
| Website | Logical grouping of stores; shares catalog, customer data | Mage_Core_Model_Website | website_id, code, name |
| Store/Store Group | Associates root category with website | Mage_Core_Model_Store_Group | group_id, website_id, root_category_id |
| Store View | Individual storefront with unique locale/theme | Mage_Core_Model_Store | store_id, code, name, website_id, group_id |
Sources: app/code/core/Mage/Core/Model/Store.php37-115 app/code/core/Mage/Core/Model/App.php142-160
The multi-store architecture is implemented through primary database tables mapped to core models. The configuration defines these entities under the core_resource node.
Configuration values are stored with scope identifiers in the database. The Mage_Core_Model_Store class provides constants for common configuration paths used across the system:
| Path Constant | Value | Description |
|---|---|---|
XML_PATH_UNSECURE_BASE_URL | web/unsecure/base_url | Unsecure frontend URL |
XML_PATH_SECURE_BASE_URL | web/secure/base_url | Secure frontend URL |
XML_PATH_PRICE_SCOPE | catalog/price/scope | Global vs Website price scope |
XML_PATH_STORE_IN_URL | web/url/use_store | Whether to include store code in URLs |
Sources: app/code/core/Mage/Core/Model/Store.php48-67 app/code/core/Mage/Core/Model/Store.php248-256
The primary method for accessing store-scoped configuration is Mage::getStoreConfig(). This method delegates to the current application instance to retrieve the store object and then its configuration.
Internal Flow:
Sources: app/code/core/Mage/Core/Model/Store.php172-183 app/code/core/Mage/Core/Model/App.php742-758
The Mage_Core_Controller_Varien_Front class manages the dispatch process, which is store-aware.
During init(), the front controller collects routers defined in the configuration path web/routers. It uses the current store's configuration to determine which routers are active and their respective classes.
If the request is not for the admin area, Maho uses a rewrite controller to check for store-specific URL rewrites stored in the database. Store switching is often triggered by the ___store parameter in the URL or based on the host/path mapping.
| URL Component | Description | Constant/Method |
|---|---|---|
| Store Code | Added to URL path if enabled | Mage_Core_Model_Store::XML_PATH_STORE_IN_URL |
| Unsecure URL | Unsecure base URL | Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL |
| Secure URL | Secure base URL | Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL |
Sources: app/code/core/Mage/Core/Controller/Varien/Front.php125-152 app/code/core/Mage/Core/Model/Store.php51-62
Products must be assigned to a website to be visible in any of that website's store views. This is managed by catalog resource models. The URL generation also respects store root categories.
Prices can be configured to be either Global or Website scoped. This is controlled by the configuration path catalog/price/scope.
Mage_Core_Model_Store::PRICE_SCOPE_GLOBAL (0) - One price for all stores.Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE (1) - Different prices per website.Sources: app/code/core/Mage/Core/Model/Store.php66-76 app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php58-60 app/code/core/Mage/Catalog/Model/Url.php203-215
Translations and locale settings are scoped per store view. The Mage_Core_Model_Translate_Inline model checks permissions per store to determine if inline translation is active.
Design packages and themes are determined based on store configuration. The Mage_Core_Model_Design_Package class resolves the package and theme to use by querying the store config.
Sources: app/code/core/Mage/Core/Model/Design/Package.php114-117 app/code/core/Mage/Core/Model/Translate/Inline.php116-139
During the application bootstrap, Mage_Core_Model_App initializes the environment and determines the current store scope. If the application is installed, it calls _initCurrentStore($code, $type) to set up the active store based on parameters passed to Mage::run().
Sources: app/code/core/Mage/Core/Model/App.php248-272
The layout system is inherently store-aware. When loading layout handles, Maho automatically adds a store-specific handle: STORE_[store_code]. This allows developers to apply layout XML changes that only affect a specific store view.
Sources: app/code/core/Mage/Core/Controller/Varien/Action.php243-260
| Class | Purpose |
|---|---|
Mage_Core_Model_Store | The "Store View" level; handles locale-specific data, currency, and configuration retrieval. |
Mage_Core_Model_Website | Represents the Website level; manages groups and provides website-scoped configuration. |
Mage_Core_Model_App | Orchestrates store initialization and provides access to current store/website objects. |
Mage_Core_Controller_Varien_Front | Front controller that initializes routers based on store-specific configuration. |
Mage_Core_Model_Design_Package | Manages theme and design resolution per store scope. |
Sources: app/code/core/Mage/Core/Model/Store.php37-148 app/code/core/Mage/Core/Model/App.php18-194 app/code/core/Mage/Core/Controller/Varien/Front.php125-152 app/code/core/Mage/Core/Model/Design/Package.php13-107
Refresh this wiki