DI Preferences

The Store module defines many DI preferences to bind interfaces to concrete implementations. These are among the most fundamental bindings in Magento.

Core Service Bindings

Interface Implementation
StoreManagerInterface Magento\Store\Model\StoreManager
StoreResolverInterface Magento\Store\Model\StoreResolver
StoreRepositoryInterface Magento\Store\Model\StoreRepository
WebsiteRepositoryInterface Magento\Store\Model\WebsiteRepository
GroupRepositoryInterface Magento\Store\Model\GroupRepository
StoreCookieManagerInterface Magento\Store\Model\StoreCookieManager
StoreConfigManagerInterface Magento\Store\Model\Service\StoreConfigManager

Data Interface Bindings

Interface Implementation
Data\StoreInterface Magento\Store\Model\Store
Data\WebsiteInterface Magento\Store\Model\Website
Data\GroupInterface Magento\Store\Model\Group
Data\StoreConfigInterface Magento\Store\Model\Data\StoreConfig

Framework Bindings

Interface Implementation
ScopeResolverInterface Magento\Store\Model\Resolver\Store
App\ScopeResolverInterface Magento\Store\Model\Resolver\Store
LocaleResolverInterface Magento\Store\Model\Resolver\Locale
UrlModifierInterface Magento\Store\Url\Plugin\RouteParamsResolver

Plugins

The Store module defines several plugins that intercept core application behavior for store context management.

storeCheck
Magento\Store\App\FrontController\Plugin\RequestPreprocessor
Magento\Framework\App\FrontControllerInterface
before beforeDispatch
Validates store code from URL/request before dispatching. Redirects to correct store URL if store code in URL is invalid or missing when required.
storeUrlSecurityInfo
Magento\Store\Url\Plugin\SecurityInfo
Magento\Framework\Url\SecurityInfoInterface
around aroundIsSecure
Determines if a URL should use HTTPS based on store-level configuration for secure URLs in frontend/admin.
storeUrlRouteParamsResolver
Magento\Store\Url\Plugin\RouteParamsResolver
Magento\Framework\Url\RouteParamsResolverInterface
before beforeSetRouteParams
Extracts _scope and _scope_to_url parameters from route params for multi-store URL generation.
storeCookieValidate
Magento\Store\Model\Plugin\StoreCookie
Magento\Framework\App\FrontControllerInterface
before beforeDispatch
Validates store cookie value. If the stored store code is invalid (store deleted or disabled), clears the cookie to prevent errors.
genericHeaderPlugin
Magento\Store\Model\HeaderProvider\UpgradeInsecure
Magento\Framework\App\Response\HeaderManager
after afterGetHeaderValue
Adds Upgrade-Insecure-Requests header based on store configuration to enforce HTTPS upgrade for browsers.

Virtual Types

The Store module defines virtual types for specialized collection fetching strategies and cached data access.

simpleCollectionFetchStrategy
Base: Magento\Store\Model\ResourceModel\Website\Collection\FetchStrategy
Optimized fetch strategy for website collections
simpleStoreFetchStrategy
Base: Magento\Store\Model\ResourceModel\Store\Collection\FetchStrategy
Optimized fetch strategy for store collections
simpleGroupFetchStrategy
Base: Magento\Store\Model\ResourceModel\Group\Collection\FetchStrategy
Optimized fetch strategy for group collections
storeRelationsLogger
Base: Magento\Framework\Logger\Monolog
Logger for store relation operations (debug purposes)

Configuration XML Example

Example of the di.xml structure showing how preferences and plugins are defined.

<config xmlns:xsi="..."> <!-- Service preferences --> <preference for="Magento\Store\Model\StoreManagerInterface" type="Magento\Store\Model\StoreManager"/> <preference for="Magento\Store\Api\StoreResolverInterface" type="Magento\Store\Model\StoreResolver"/> <!-- Plugins --> <type name="Magento\Framework\App\FrontControllerInterface"> <plugin name="storeCheck" type="Magento\Store\App\FrontController\Plugin\RequestPreprocessor" sortOrder="10"/> <plugin name="storeCookieValidate" type="Magento\Store\Model\Plugin\StoreCookie" sortOrder="20"/> </type> <!-- Virtual type for cached collection --> <virtualType name="simpleCollectionFetchStrategy" type="Magento\Store\Model\ResourceModel\Website\Collection\FetchStrategy"> <arguments> <argument name="cache" xsi:type="object"> Magento\Framework\App\Cache\Type\Collection </argument> </arguments> </virtualType> </config>

Observers

The Store module does not define its own events.xml file in the core module. However, other modules observe store-related events.

No events.xml in Magento_Store

The Magento_Store module is a foundational module that other modules depend on. It primarily uses the DI system (preferences and plugins) rather than the event/observer pattern. Store-related events like store_add, store_delete, and store_edit are dispatched but observed by other modules.

Events Dispatched by Store Module

Event Name Dispatched From Data
store_add Store::afterSave() store object
store_edit Store::afterSave() store object
store_delete Store::afterDelete() store object
store_group_save Group::afterSave() group object
website_save_after Website::afterSave() website object