Exploring the Store package and its init process with scopes in Magento2 (1.0.0-beta).
See the previous post where we’ve explored the differences between Magento 1.9 and Magento 2 0.74.0 regarding Scopes and Websites, Groups and Stores.
@todo
StoreManager
With Magento2 there has been introduced the Magento\Store\Model\StoreManager
which is responsible for resolving the correct store during a request.
The StoreManager also defines the MAGE_RUN_CODE
and MAGE_RUN_TYPE
environment variables which are used in
Nginx or Apache config to force set a specific website, store group or store view to a domain/path/etc.
In PHP (especially in the index.php) it can be written like (don’t do that in the core file):
$_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website_code|group_id|store_code';
$_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website|group|store';
Yes you can even set the group_id in MAGE_RUN_CODE
when MAGE_RUN_TYPE
is group
.
StoreResolver
The StorageFactory has been replaced with the StoreResolver…
StoresConfig
With Magento2 there has been introduced the Magento\Store\Model\StoresConfig
which is a convenience helper class to retrieve (with method getStoresConfigByPath()
) for a
config path all config values for each store view. Only used in Customer group to check if the
current group is the default group to create an account AND in \Magento\Sales\Model\Observer\CleanExpiredQuotes
to clean the expired quotes.