VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/3.8-store-and-multi-store-architecture

⇱ Store and Multi-Store Architecture | MahoCommerce/maho | DeepWiki


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

Store and Multi-Store Architecture

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.


Scope Hierarchy

Maho's multi-store architecture is built on a three-level hierarchy where each level can have different configurations and settings:


Hierarchy Levels:

LevelPurposeCode EntityKey Attributes
Global (Default)Base configuration for entire installationMage_Core_Model_ConfigInherited by all websites/stores
WebsiteLogical grouping of stores; shares catalog, customer dataMage_Core_Model_Websitewebsite_id, code, name
Store/Store GroupAssociates root category with websiteMage_Core_Model_Store_Groupgroup_id, website_id, root_category_id
Store ViewIndividual storefront with unique locale/themeMage_Core_Model_Storestore_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


Database Schema and Entities

Core Tables and Model Mapping

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 Data Structure

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 ConstantValueDescription
XML_PATH_UNSECURE_BASE_URLweb/unsecure/base_urlUnsecure frontend URL
XML_PATH_SECURE_BASE_URLweb/secure/base_urlSecure frontend URL
XML_PATH_PRICE_SCOPEcatalog/price/scopeGlobal vs Website price scope
XML_PATH_STORE_IN_URLweb/url/use_storeWhether 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


Configuration Retrieval API

Accessing Store Configuration

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


Multi-Store Request Routing

The Mage_Core_Controller_Varien_Front class manages the dispatch process, which is store-aware.

Router Initialization

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.


URL Rewrites and Store Switching

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 ComponentDescriptionConstant/Method
Store CodeAdded to URL path if enabledMage_Core_Model_Store::XML_PATH_STORE_IN_URL
Unsecure URLUnsecure base URLMage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL
Secure URLSecure base URLMage_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


Product and Catalog Scope

Website Association

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.


Price Scope

Prices can be configured to be either Global or Website scoped. This is controlled by the configuration path catalog/price/scope.

  • Global: Mage_Core_Model_Store::PRICE_SCOPE_GLOBAL (0) - One price for all stores.
  • Website: 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


Store-Specific Rendering and Localization

Translations and Locale

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 and Themes

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


Store-Aware Application Logic

Request Initialization

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

Layout and Themes

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


Summary of Key Classes

ClassPurpose
Mage_Core_Model_StoreThe "Store View" level; handles locale-specific data, currency, and configuration retrieval.
Mage_Core_Model_WebsiteRepresents the Website level; manages groups and provides website-scoped configuration.
Mage_Core_Model_AppOrchestrates store initialization and provides access to current store/website objects.
Mage_Core_Controller_Varien_FrontFront controller that initializes routers based on store-specific configuration.
Mage_Core_Model_Design_PackageManages 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