Magento 1.9 – Disable Module for Specific Store View

magento-1.9multistorestore-view

We have a website with 2 store views.

One is the frontend that the public sees the other is an 'offline' store that runs a POS system for our staff. I want the offline store to be a completely standard version of magento i.e. run none of the many theme and extra modules we have running on our live store.

I have set the theme to default but now I need to disable the modules. Is there a way to edit the module.xml files so that for the particular store view <active>false</active> or something that achieves that?

Best Answer

First Move app/code/core/Mage/Core/Model/Config.php to app/code/local/Mage/Core/Model/Config.php

Now open app/code/local/Mage/Core/Model/Config.php and find method called loadModulesConfiguration and add the following code to make the method look like this.

public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel=null)
{
    $disableLocalModules = !$this->_canUseLocalModules();

    if ($mergeToObject === null) {
        $mergeToObject = clone $this->_prototype;
        $mergeToObject->loadString('<config/>');
    }
    if ($mergeModel === null) {
        $mergeModel = clone $this->_prototype;
    }
    $modules = $this->getNode('modules')->children();
    foreach ($modules as $modName=>$module) {
        if ($module->is('active')) {
            // Begin additional code
            if((bool)$module->restricted) {
                $restricted = explode(',', (string)$module->restricted);
                $runCode = (isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'default');
                if(in_array($runCode, $restricted)) {
                    continue;
                }
            }
            // End additional code
            if ($disableLocalModules && ('local' === (string)$module->codePool)) {
                continue;
            }
            if (!is_array($fileName)) {
                $fileName = array($fileName);
            }

            foreach ($fileName as $configFile) {
                $configFile = $this->getModuleDir('etc', $modName).DS.$configFile;
                if ($mergeModel->loadFile($configFile)) {
                    $mergeToObject->extend($mergeModel, true);
                }
            }
        }
    }
    return $mergeToObject;
}

Now Edit your module.xml file

<?xml version="1.0"?>
<config>
    <modules>
        <MyPackage_MyModule>
            <active>false</active>
            <restricted>mystore1,mystore4,mystore5</restricted>
            <codePool>local</codePool>
        </MyPackage_MyModule>
    </modules>
</config>
Related Topic