I’ve been working on adding a corporate section to a magento website lately and realised one thing: I’m bored.
I have 2 domains, one for the corporate website and one for the store. The corporate website will have its own template and catalogue of products but with a “Email for Quote” or something along those lines. The store website will be.. well, a fucking store.
So first you create the stores along with the store views (Magento backend -> System-> Manage Stores), then you go in the configuration page and set up the store view scopes so that each base url is set to the appropriate domain (General->Web). You should also set “Add Store Code to URLS” and “Auto-Redirect to Base URL” to Yes on a global scope.
Hopefully at this point you already have each domain pointing to the store(if not you should have 404′s all over the fucking place)
Now comes editing the index.php of the magento store! This is where the fun starts and where you’ll start hating upgrading the magento installation
Find the index.php of the main magento installation.
Somewhere at the bottom you should find somethign like this:
/* 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';
and after it there should be something like this:
Mage::run($mageRunCode, $mageRunType);
so in between put something like this:
switch($_SERVER['HTTP_HOST']) {
case 'corporate.com':
case 'www.corporate.com':
case 'http://corporate.com':
case 'http://www.corporate.com':
$mageRunCode = 'corp';
$mageRunType = 'store';
break;
case 'store.com':
case 'www.store.com':
case 'http://store.com':
case 'http://www.store.com':
$mageRunCode = 'store';
$mageRunType = 'store';
break;
}
Obviously you need to modify this to your domains and store codes(which you entered in the manage stores part)