Magento 1.7 Configuration – Difference Between $_SERVER[‘MAGE_RUN_TYPE’] ‘store’ and ‘website’

configurationmagento-1.7multistore

For the creation of multistore magento we use following code

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);

What will be the difference if we use website instead of store in $_SERVER['MAGE_RUN_TYPE'] : 'store'; code

Best Answer

I want to correct KESHAV_PHP here.

$_SERVER['MAGE_RUN_TYPE'] defines the type of entity which is used to select the store in the end. If you define a specific store by passing here store, then the store is loaded. This means espacially (in contradiction to what keshav wrote), that it doesn't matter wether the store is part of the default website or not.

If you pass website, then the store is loaded which is default for the website.

$_SERVER['MAGE_RUN_CODE'] defines the code of the website or store, as defined in the tables core_website.code and core_store.code.

The whole process can be found here:

\Mage_Core_Model_App::_initCurrentStore
switch ($scopeType) {
        case 'store':
            $this->_currentStore = $scopeCode;
            break;
        case 'group':
            $this->_currentStore = $this->_getStoreByGroup($scopeCode);
            break;
        case 'website':
            $this->_currentStore = $this->_getStoreByWebsite($scopeCode);
            break;
        default:
            $this->throwStoreException();
    }

Where getStoreByWebsite only gets the default group and then calls getStoreByGroup which gets the default store for the group.

Related Topic