Preconditions
Magento already created a default website on installation (in your case mystore1.com).
Step 1 - Creation
Go to System->Manage Stores
. Click on Create Website. Fill in the the form with desired values and save. Example:
- Name - Website 2
- Code - site2
- Sort Order: 2
Click on Create Store. In the form fill in the values and save. Example:
- Website - Website 2 (the one you created previously)
- Store for website 2
- Root Category - Default Category (same as the store in mystore1.com)
Click on Create Store View. In the form fill in the values and save. Example:
- Store
- Name - store for website 2 (the one you created above)
- Code - store2
- Status - Enabled
- Sort Order - 1
So far you have created a new website.
Step 2 - Configuration
Go to System->Configuration->Web->Unsecure
. From the top left dropdown select 'Website 2' (the website not the store view) and fill the following value.
- Base URL : http://www.mysite2.com/
- Base Link URL: {{unsecure_base_url}}
- Base Skin URL: {{unsecure_base_url}}skin/
- Base Media URL: {{unsecure_base_url}}media/
- Base JavaScript URL: {{unsecure_base_url}}js/
If some of them are already like that, leave them that way.
If you plan to use SSL on your website you should do the same on the Secure
section but fill in the secure url of your website for 'Base URL'.
- Base URL : https://www.mysite2.com/
- Base Link URL: {{secure_base_url}}
- Base Skin URL: {{secure_base_url}}skin/
- Base Media URL: {{secure_base_url}}media/
- Base JavaScript URL: {{secure_base_url}}js/
Save the changes and clear the cache.
Step 3 - Server configuration
Now you have to make the document root of mysite2.com point to the same folder as mysite1.com.
Add this to your httpd.conf
file
<VirtualHost *:80>
ServerAdmin webmaster@mysite2.com
DocumentRoot /document/root/here
ServerName mysite2.com
</VirtualHost>
Now when you visit mysite2.com you will see the same homepage as mysite1.com but the first click you make will take you to mysite1.com.
To fix this add the following to .htaccess
.
SetEnvIf Host www\.mysite1\.com MAGE_RUN_CODE=base #or the code for mysite1.com
SetEnvIf Host www\.mysite1\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^mysite1\.com MAGE_RUN_CODE=base #or the code for mysite1.com
SetEnvIf Host ^mysite1\.com MAGE_RUN_TYPE=website
SetEnvIf Host www\.mysite2\.com MAGE_RUN_CODE=site2 #or the code for mysite1.com
SetEnvIf Host www\.mysite2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^mysite2\.com MAGE_RUN_CODE=site2 #or the code for mysite1.com
SetEnvIf Host ^mysite2\.com MAGE_RUN_TYPE=website
Restart the server, clear the cache again just in case (contents of var/cache) and you should be ready.
In case I missed something you can check this tutorial that basically says the same things.
[EDIT]
After configuring the new website, in order to separate the customers go to System->Configuration->Customer Configuration->Account Sharing Options
and set the value for Share Customer Accounts to Per website.
Ok so I am not sure if this is the bug but if you compare the Magento 1.8 and Magento 1.7 versions of the function currency in Mage_Core_Model_Local you will notice a reference to a bug with Zend_Currency
Magento 1.7: Mage_Core_Model_Local->currency
/**
* Create Zend_Currency object for current locale
*
* @param string $currency
* @return Zend_Currency
*/
public function currency($currency)
{
Varien_Profiler::start('locale/currency');
if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) {
try {
$currencyObject = new Zend_Currency($currency, $this->getLocale());
} catch (Exception $e) {
$currencyObject = new Zend_Currency($this->getCurrency(), $this->getLocale());
$options = array(
'name' => $currency,
'currency' => $currency,
'symbol' => $currency
);
$currencyObject->setFormat($options);
}
self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject;
}
Varien_Profiler::stop('locale/currency');
return self::$_currencyCache[$this->getLocaleCode()][$currency];
}
Magento 1.8: Mage_Core_Model_Local->currency
/**
* Create Zend_Currency object for current locale
*
* @param string $currency
* @return Zend_Currency
*/
public function currency($currency)
{
Varien_Profiler::start('locale/currency');
if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) {
$options = array();
try {
$currencyObject = new Zend_Currency($currency, $this->getLocale());
} catch (Exception $e) {
/**
* catch specific exceptions like "Currency 'USD' not found"
* - back end falls with specific locals as Malaysia and etc.
*
* as we can see from Zend framework ticket
* http://framework.zend.com/issues/browse/ZF-10038
* zend team is not going to change it behaviour in the near time
*/
$currencyObject = new Zend_Currency($currency);
$options['name'] = $currency;
$options['currency'] = $currency;
$options['symbol'] = $currency;
}
$options = new Varien_Object($options);
Mage::dispatchEvent('currency_display_options_forming', array(
'currency_options' => $options,
'base_code' => $currency
));
$currencyObject->setFormat($options->toArray());
self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject;
}
Varien_Profiler::stop('locale/currency');
return self::$_currencyCache[$this->getLocaleCode()][$currency];
}
My suggestion would be to try updating the try catch to match that of Magento 1.8 (I know this is not the best solution and obviously I would not suggest editing the core files but adding a rewrite)
Best Answer
You could build the URL's yourself like you're suggesting but there are a couple of downsides like, for example, having a different URL key on the other store.
I always use the Emulation feature in Magento for these kinds of scenarios.
This will basically run the code as it was on a different store.
Although I did not test it might also work to set the store ID on the
catalog/product
model before loading the product.Might be worth a try.