Monday, 23 December 2019

How to create Multi Website/Stores simlinks in magento 2



1) Create a new folder in magento root and copy the index.php and .htaccess files from magento root to new folder.

2) Edit the index.php which is in new folder

Replace:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

/** @var \Magento\Framework\App\Http $app */

$app = $bootstrap->createApplication('Magento\Framework\App\Http');

$bootstrap->run($app);

Created multi website in magento, Steps to create a multistore in admin panel is same as like in magento1.x. Don't forget to change the base url and secure url for new website/store. Once made changes in admin panel follow the below steps,

1) Create a new folder in magento root and copy the index.php and .htaccess files from magento root to new folder.

2) Edit the index.php which is in new folder

Replace:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

/** @var \Magento\Framework\App\Http $app */

$app = $bootstrap->createApplication('Magento\Framework\App\Http');

$bootstrap->run($app);
With:

$params = $_SERVER;

$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'newstore'; //Webite code as same in admin panel

$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');

$bootstrap->run($app);

And also update bootstrap.php include path as below,

Replace:

require __DIR__ . '/app/bootstrap.php';
With:

require __DIR__ . '/../app/bootstrap.php';


3) Create a simlinks inside the new folder

ln -s from path/app to path/app

ln -s from path/lib to path/lib

ln -s from path/pub to path/pub

ln -s from path/var to path/var

For example /var/www/html/app cnsv/app

No comments:

Post a Comment