2

I have a client who is in need of a store with multiple, independent currency rates. They cannot use the default rate functionality of Magento due to them needing bespoke prices for each currency and product.

To battle this we decided to create a website per currency. However, we also need two store groups and store views for each site. Is there a way to set-up Magento whereby it would be something like the following:

domain.com/website1/store1
domain.com/website1/store2

domain.com/website2/store1
domain.com/website2/store2

I have read of many ways to do each separately (i.e. domain per website and subfolder per store) but not of having both in the URL.

The way I was looking to do this was with a symlink, but I just can't wrap my head around where to start!

Any help would be appreciated, thank you.

4

I used to do it like this:
create the folders website1/store1, website1/store2, ...
Then, in the folder website1 clone the index.php and .htaccess from the rood folder and replace this in index.php

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';

with

$mageFilename =  '../app/Mage.php';

and replace

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

with

Mage::run('website1_code_goes_here', 'website');

Do the same for the folder website2 but change the code accordingly on the last line I mentioned.

Then copy the same files in the folder website1/store1 and change

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';

with

$mageFilename = '../../app/Mage.php';

and

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

with

Mage::run('store1_id_goes_here', 'store');

Do the same for the other store folders (website1/store2, website2/store1, website2/store2) adjusting the last line accordingly.

Then you will have to go to System->configuration->web->unsecure in the backend, select from the top left selector, website1 and fill in the base url field to http://www.domain.com/website1/. Do the same for base link url.
and for media base url fill in http://www.domain.com/media/. The same goes for skin and js urls.

Do the same for website 2.
Then select from the top left selector the store view store1.
Fill in the base url to http://www.domain.com/website1/store1/ and the same for base link url. I don't think there is a need to change the values for base media/skin/js url.
Do the same for the 3 others store views.

Clear the cache and give it a go.

  • You're a genius. Cheers mate. – Richard Cripps Aug 20 '15 at 13:10
  • We had to set RewriteBase from / to /folder_name/ too. Maybe worth to mention? – sv3n Jul 21 '17 at 14:09
  • @marius : I just want to know, is possible changing header and footer for multi-store using the same theme. – zus Dec 25 '17 at 12:11
0

Create a Websites and it's relevant Store and StoreView from Admin > Stores > All Stores Go to Stores > Configuration, Select website which you have created. Then Go to Web and change both Base URLs & Base URLs (Secure)

For example : e.g. Base URL: xyz.com (Main website url keep as it is) Base Link URL: {{unsecure_base_url}}web2/

Here, web2 is a sub directory folder which needs to create under your magento root folder

Create a sub directory folder, then copy index.php & .htaccess from root

Open index.php replace everything with the code bellow:

require realpath(__DIR__) . '/../app/bootstrap.php';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'web2_website'; 
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; 
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);

web2_website is a website code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.