1. Store Resolution Flow
Store resolution occurs during application bootstrap to determine which store view to use for the current request. This affects all scoped configuration, URLs, and content.
Store Resolution Priority
2. Scope Configuration Resolution
When ScopeConfigInterface::getValue() is called, configuration values are resolved
with proper fallback from store -> website -> default scope.
Configuration data is heavily cached. The entire core_config_data table is loaded
into memory and cached by scope. Use bin/magento cache:flush config after
programmatic config changes.
3. Store Switching Flow
When a customer switches stores (e.g., via store switcher dropdown), several steps ensure proper redirection and state management.
-
Customer clicks store switcher linkLink format:
/stores/store/redirect/?___store=french&___from_store=default -
Redirect controller validates store codesEnsures both source and target stores exist and are active
-
StoreCookieManager::setStoreCookie($store)Persists selected store in cookie for future requests
-
URL Rewrite lookup for target storeAttempts to find equivalent URL in target store
-
Redirect to target store URLMaintains URL path if possible, or redirects to home
4. Multi-Store URL Generation
URL generation must account for store-specific base URLs, URL rewrites, and store codes in path.
Each store can have a different base URL configured in web/unsecure/base_url and
web/secure/base_url. This enables subdomain-based multi-store setups
(e.g., uk.example.com, de.example.com).
5. Store Repository Caching Flow
The StoreRepository implements in-memory caching to avoid repeated database queries.
Cache Invalidation
6. Single Store Mode Detection
Single store mode simplifies the admin UI when only one store view exists.
Magento always has an "admin" store with ID 0. This is why hasSingleStore()
checks for < 3 stores: admin (0) + one real store = 2 is still "single store".