Last active
November 19, 2019 15:07
-
-
Save DavaGordon/0ebbae9e8b0ad7b80245da58f40262b9 to your computer and use it in GitHub Desktop.
Magento 2 Multi Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Application entry point | |
* | |
* Example - run a particular store or website: | |
* -------------------------------------------- | |
* require __DIR__ . '/app/bootstrap.php'; | |
* $params = $_SERVER; | |
* $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2'; | |
* $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; | |
* $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); | |
* \/** @var \Magento\Framework\App\Http $app *\/ | |
* $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); | |
* $bootstrap->run($app); | |
* -------------------------------------------- | |
* | |
* Copyright © Magento, Inc. All rights reserved. | |
* See COPYING.txt for license details. | |
*/ | |
try { | |
require __DIR__ . '/app/bootstrap.php'; | |
} catch (\Exception $e) { | |
echo <<<HTML | |
<div style="font:12px/1.35em arial, helvetica, sans-serif;"> | |
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"> | |
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> | |
Autoload error</h3> | |
</div> | |
<p>{$e->getMessage()}</p> | |
</div> | |
HTML; | |
exit(1); | |
} | |
switch($_SERVER['HTTP_HOST']) { | |
case 'domain.local': | |
case 'www.domain.local': | |
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '1'; | |
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; | |
break; | |
case 'domain2.local': | |
case 'www.domain2.local': | |
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '2'; | |
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; | |
break; | |
} | |
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); | |
/** @var \Magento\Framework\App\Http $app */ | |
$app = $bootstrap->createApplication('Magento\Framework\App\Http'); | |
$bootstrap->run($app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment