Adding Another Store In Magento
The first thing we need to do is setup our second store in Magento.We're going to do a hypothetical here for the naming conventions, and assume we own
shirts.com
. Adjust the values accordingly for your own store.- Login to the Magento admin.
- Go to the Catalog tab, and select Manage Categories.
- Click on the Add Root Category button on the left.
- On the right, for the Name, we'll enter
Shoes.com
. Set the dropdown toYes
for both Is Active and Is Anchor. - Click the Save Category button.
- Go to the System tab and select Manage Stores.
- Click on the Create Website button.
- For the Name, we'll enter
Shoes.com
, and for the Code, we'll entershoes
. We'll use this value later, so don't forget this! - Click the Save Website button.
- Click on the Create Store button.
- For the Website, select
Shoes.com
from the dropdown. For the Name, we'll enterMain Store
. For the Root Category, select theShoes.com
from the dropdown. - Click on the Save Store button.
- Click on the Create Store View button.
- For the Store, select
Main Store
from the dropdown, making sure it's for theShoes.com
website. For the Name, we'll enterEnglish
. For the Code, we'll entershoes_en
. For the Status, selectEnabled
from the dropdown. - Click the Save Store View button.
- Go to the System tab and select Configuration.
- For the Current Configuration Scope (located on the top left), change the dropdown menu from
Default Config
toShoes.com
. - Select Web from the sidebar on the left under the General heading.
- For both the Unsecure and Secure sections, uncheck the Use default box next to the Base URL item, and enter the URL for your store, e.g.
http://www.shoes.com/
. Don't forget the trailing slash! - Click the Save Config button.
If the URL structure you've chosen will have different domains for each store, the parked domain method is the fastest and easiest method.
Parked Domain Method
For this method, we'll pretend we ownshirts.com
and shoes.com
. The shirts.com
domain is our primary domain, and Magento is already installed on it. Here's how we would set this up for the shoes.com
domain:- Login to cPanel for your domain and click on the Parked Domains icon.
- In the input field, enter the domain name that you'll be setting up as a second store, e.g.
shoes.com
. - Click on the Add Domain button.
- Open up the
index.php
file for Magento and look for this line (it's the last line of the file):
…and right before this, we're going to add the following code:Mage::run($mageRunCode, $mageRunType);
If you have more than two stores, you will need to add additional cases to the above code block, e.g.:switch($_SERVER['HTTP_HOST']) { case 'shoes.com': case 'www.shoes.com': $mageRunCode = 'shoes'; $mageRunType = 'website'; break; }
switch($_SERVER['HTTP_HOST']) { case 'shoes.com': case 'www.shoes.com': $mageRunCode = 'shoes'; $mageRunType = 'website'; break; case 'hats.com': case 'www.hats.com': $mageRunCode = 'hats'; $mageRunType = 'website'; break; }
Addon Domain Method
This is the same scenario as above, except it takes a little longer to setup. This method might be more useful to you if, for example, you wanted to have a blog on one domain, but not on the other. You couldn't do that with a parked domain. Here's how we would set this up for theshoes.com
domain:- Login to cPanel for your domain, and click on the Addon Domains icon.
- For the New Domain Name, we'll enter
shoes.com
. cPanel will automatically fill in the next two fields, so removepublic_html/
from the Document Root field, leaving us with justshoes.com
. This step isn't required, but for organizational purposes, it makes more sense. - Set a password for this domain and click on the Add Domain button.
- Login to your site via SSH, and go to the directory that we previously set in the Document Root field above when adding our domain. In our case, we would do the following:
cd shoes.com/
- Copy the
index.php
and.htaccess
file from the directory where Magento is installed, which would be in our root web directory:cp ../public_html/index.php ../public_html/.htaccess .
- Open up the
index.php
file that we just copied over and replace the following line of code:
…with the following:$mageFilename = 'app/Mage.php';
$mageFilename = '../public_html/app/Mage.php';
- With the
index.php
file still open, look for this line (it's the last line of the file):
…and right before this, we're going to add the following code:Mage::run($mageRunCode, $mageRunType);
$mageRunCode = 'shoes'; $mageRunType = 'website';
- Lastly, we need to create symbolic links to point to a few directories:
ln -s ../public_html/app ./app ln -s ../public_html/errors ./errors ln -s ../public_html/includes ./includes ln -s ../public_html/js ./js ln -s ../public_html/lib ./lib ln -s ../public_html/media ./media ln -s ../public_html/skin ./skin ln -s ../public_html/var ./var
Subdomain Method
For this method, we'll pretend we ownmall.com
, and it's setup as a portal that links to the various shops within the mall. Magento will be installed on the mall.com
domain, and all of the shops will be in subdomains, e.g.:shoes.mall.com
shirts.mall.com
shoes
subdomain:- Login to cPanel for your domain, and click on the Subdomains icon.
- For the Subdomain, we'll enter
shoes
. cPanel will automatically fill in the next field, so removepublic_html/
from the Document Root field, leaving us with justshoes
. This step isn't required, but for organizational purposes, it makes more sense. - Click the Create button.
- Login to your site via SSH, and go to the directory that we previously set in the Document Root field above when creating our subdomain. In our case, we would do the following:
cd shoes/
- Copy the
index.php
and.htaccess
file from the directory where Magento is installed, which would be in our root web directory:cp ../public_html/index.php ../public_html/.htaccess .
- Open up the
index.php
file that we just copied over and replace the following line of code:
…with the following:$mageFilename = 'app/Mage.php';
$mageFilename = '../public_html/app/Mage.php';
- With the
index.php
file still open, look for this line (it's the last line of the file):
…and right before this, we're going to add the following code:Mage::run($mageRunCode, $mageRunType);
$mageRunCode = 'shoes'; $mageRunType = 'website';
- Lastly, we need to create symbolic links to point to a few directories:
ln -s ../public_html/app ./app ln -s ../public_html/errors ./errors ln -s ../public_html/includes ./includes ln -s ../public_html/js ./js ln -s ../public_html/lib ./lib ln -s ../public_html/media ./media ln -s ../public_html/skin ./skin ln -s ../public_html/var ./var
Subdirectory Method
This is the same scenario as above, except all of the shops will be in subdirectories, e.g.:mall.com/shoes
mall.com/shirts
shoes
subdirectory:- Login to your site via SSH, and create a subdirectory where your second store will be:
cd public_html mkdir shoes/ cd shoes/
- Copy the
index.php
and.htaccess
file from the directory where Magento is installed, which would be in our root web directory:cp ../public_html/index.php ../public_html/.htaccess .
- Open up the
index.php
file that we just copied over and replace the following line of code:
…with the following:$mageFilename = 'app/Mage.php';
$mageFilename = '../public_html/app/Mage.php';
- With the
index.php
file still open, look for this line (it's the last line of the file):
…and right before this, we're going to add the following code:Mage::run($mageRunCode, $mageRunType);
$mageRunCode = 'shoes'; $mageRunType = 'website';
Managing Multiple Stores
It's very important to remember that now that you have multiple stores to manage from one admin panel, that you make sure you're changing the configuration for the appropriate store.In the System → Configuration section, if you leave the dropdown menu for Current Configuration Scope set to
Default Config
, it will globally change the values for all of your stores, assuming you haven't removed the checkmark next to Use default throughout the configuration sections.You can change the configuration values globally, for each website, and for individual store views.
Secure Checkout For Each Store
For those of you in dedicated hosting environments, you can follow either the addon or parked domain method from above, and edit thehttpd.conf
file to give the addon or parked domain a dedicated IP address.However, this is not advised. Your changes will most likely be overwritten with a control panel upgrade, Apache or PHP rebuild, or even simple maintenance.
Your best bet would be to setup each store as a separate account, which can be done in WHM if you have access to it, or in the case of our Split-Dedicated product, something we will be able to set up for you.
Once you have all of your domains setup as individual accounts, you would follow steps 5, 7 and 8 for the addon domain method, except you're going to use absolute paths instead of relative paths for the symbolic links, e.g.:
ln -s /home/username/public_html/app ./app
ln -s /home/username/public_html/errors ./errors
ln -s /home/username/public_html/includes ./includes
ln -s /home/username/public_html/js ./js
ln -s /home/username/public_html/lib ./lib
ln -s /home/username/public_html/media ./media
ln -s /home/username/public_html/skin ./skin
ln -s /home/username/public_html/var ./var
Lastly, in order for the above to work, you will need suEXEC
disabled. This won't be a problem in a dedicated hosting environment,
since you don't have to worry about other people being able to access
your files.This is just one of the many advantages of running your online business in a more secure and flexible hosting environment like this. If you're on our Split-Dedicated product, this is something we'll have to disable for you.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.