Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

My Multiple Stores Setup Now Works
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 


IMPORTANT! This has been updated, please see post below on how to set it up...

Hi there,

I have two stores set up under one website and it was all going smoothly. Nice being able to share the shopping cart, have different tracking, new design etc.

However, if I go directly to the URL without having selected the correct store I get a 404 error. So for instance:

Example setup:

Shoe Store
Shoe Category 1
Shoe Product 1 (with URL of http://www.mystore.com/shoe-product-1.html)
Jeans Store
Jeans Category 1
Jeans Product 1 (with URL of http://www.mystore.com/jeans-product-1.html)

Now if I am in the Shoe Store and enter the URL directly into my address bar of http://www.mystore.com/shoe-product-1.html then it works fine as that product is contained within the Shoe Store. However, if I type in http://www.mystore.com/jeans-product-1.html to the address bar, I receive a 404 error.

If I then switch to the Jeans Store and enter the same URL that failed last time then it is fine as that product is contained within the Jeans Store. If however I enter the first URL for the shoe product, this still works, but using the Jeans Store template.

My concern is that if someone has visited my website before and click on a link from a search engine, then they will receive a 404 error if they have been in a different section of the site even though the product/category exists.

I tried to set it up using subfolders but had the same problem?!?

Can anybody help or tell me what I’m doing wrong? It seems odd to me, as I would believe the scope for the URLs is per website as the shopping cart is.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

I have also noticed that when I go to the generated site map it only list products from the first store of the website no matter which store I may happen to be in?

Me bigging silly, the site maps generate per store. This still seems weird to me as I have ‘two stores’ under one ‘website’. I would want my sitemap to show the 2 stores on the same sitemap?!?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

Bump!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  290
Joined:  2008-01-04
 

This has also been a concern of mine as well. The reason that you are receiving a 404 is because Mage is running the “default” store. If you notice when you use the store switcher, you will see /?store=new_store_name appended to the initial url. Once you navigate to the first product and/or category in that store it drops the appended store modifier and you browse as normal. Yes, multi-store functionality is nice but I don’t know how it will function in search engine spidering, bookmarking etc. To see what I mean, try adding /?store=your_store_name to the end of the url that returns a 404. I wish I knew a good fix for this, but I don’t.

Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

OK, well finally I worked this out. In my case the easiest way was to add my store as a sub directory. So here’s what I did for those having the same problem.

-------------------------------------------------------------------------------------------------

Adding multiple stores

This assumes that you want to create 2 or more stores in the same website and this was built using Magento 1.0.

-------------------------------------------------------------------------------------------------

Creating the right directories and files

- Create a new directory in the main web directory (for example /store2 - bear in mind that I have Magento installed in the root web directory, not in a folder).

- Copy over the main index.php file and the .htaccess file into this new folder.

- Amend the index.php file: change $mageFilename = app/Mage.php’; to $mageFilename = ‘../app/Mage.php’; and then change Mage::run(’default’); to Mage::run(’store2_uk’);. The run command should point to the default store view for the new store. So it means that when someone goes to http://www.mywebsite.com/store2/ they will then get the default store view which in this example is store2_uk

- Now update the .htaccess file in this directory. Set RewriteBase to the new directory’s name, so in this case we would use RewriteBase /store2/.

-------------------------------------------------------------------------------------------------

Creating a new store in the admin

Creating the new store in the admin is done by going to System->Manage Stores. You should already have a website set up, one store and one store view. Think of the website as the whole environment for sharing things like the shopping cart, user accounts etc., the store as a way of combining separate stores under one main website (e.g. your website could be selling fashion, and you may have 3 stores: a clothes store, a shoe store, and an accessories store that are all under the same website brand), and a store view as a skin for the individual store (good for design changes and language changes).

- So create a new store and then choose the main website from the Website dropdown, give it a name e.g. Store 2, choose a root category (you should have a separate root category for the store e.g. shoes).

- Create your default store view for the new store and choose your new store (e.g.Store 2) from the store dropdown, give it a name (e.g. UK Store 2), then give it a code of store2_uk (this is the name that is referenced by the Mage::run(’store2_uk’) in our index.php file), set the status to enabled and if you want to add lots of store views you can order their display order with the final box.

-------------------------------------------------------------------------------------------------

Set up the configuration for the new store

You can now change all the configuration settings for this new store, but to get it working you will need to go to System->Manage Configuration.

- From Current Configuration Scope: in the top left, choose your new store view (e.g. Store 2 -> UK Store 2). Now choose Web from the General box situated in the menu on the left.

Below we will just address sites without SSLs so will only amend the unsecure section, but you can use the example for secure settings too (you’d just need to use your secure domain):

- Untick the Use Website box next to Base URL and enter your website URL (with a forward slash at the end) e.g. http://www.mywebsite.com/

- Now to get everything to work with the new store simply untick the Use Website box next to Base Link URL and enter the name of your new directory at the end e.g. {{unsecure_base_url}}store2/.

-------------------------------------------------------------------------------------------------


Testing it out

Now go to http://www.mywebsite.com/store2/ and you should see your new store view (you may need to build a home page for it). All urls should now also work and change the store accordingly, so you will not need ’?store=‘ at the end of the URL.

-------------------------------------------------------------------------------------------------

Hope this has helped.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mozo
Jr. Member
 
Total Posts:  2
Joined:  2008-04-20
 
dan_w - 22 April 2008 05:41 AM

This has also been a concern of mine as well. The reason that you are receiving a 404 is because Mage is running the “default” store. If you notice when you use the store switcher, you will see /?store=new_store_name appended to the initial url. Once you navigate to the first product and/or category in that store it drops the appended store modifier and you browse as normal. Yes, multi-store functionality is nice but I don’t know how it will function in search engine spidering, bookmarking etc. To see what I mean, try adding /?store=your_store_name to the end of the url that returns a 404. I wish I knew a good fix for this, but I don’t.

Dan

Anyone found a solution to this??

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshwebs
Sr. Member
 
Total Posts:  153
Joined:  2008-05-27
Leicestershire, UK
 

Hi Wiseguy,
Thanks for this. I did something v.similar to get another store working b4 coming across this post - the 2 things different for me was that I didn’t change the RewriteBAse rule in .htqaccess - mine is # commented & adding /mystore2/ leads to an apache ‘object not found’. This could be due to my second difference - in the base url I put the full path to the new store - so mine was http://localhost/magento/store2/ .

What I haven’t achieved yet is the following - on the default demo store there is the site switcher drop down. My store2 is referenced in my default store site switcher. Is this because of the differences I outlined above?

Thanks
Eddie

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

Uhm, I’m sorry but i’m wondering why are you doing this when you can enable “Store code in url” with the same result?

I’m missing something?

 
Magento Community Magento Community
Magento Community
Magento Community
 
RulerOfNations
Jr. Member
 
Total Posts:  2
Joined:  2008-07-10
 
Pukos - 10 July 2008 08:25 AM

Uhm, I’m sorry but i’m wondering why are you doing this when you can enable “Store code in url” with the same result?

I’m missing something?

Pukos,
Where do you enable “Store code in URL”?

Thanks,
Ruler Of Nations

 
Magento Community Magento Community
Magento Community
Magento Community
 
ukdazza
Guru
 
Total Posts:  308
Joined:  2008-04-16
 

Pukos can you explain your point. I don’t want to do the long way above if there is a quicker and easier way.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  290
Joined:  2008-01-04
 

In previous versions, there wasn’t a “ Add Store Code to Urls”. Now there is though, which can eliminate the need to have different stores in different directories. The option can be turned on/off under configuration->general->web

 
Magento Community Magento Community
Magento Community
Magento Community
 
ukdazza
Guru
 
Total Posts:  308
Joined:  2008-04-16
 

I don’t understand what “add store code to urls” means…

 
Magento Community Magento Community
Magento Community
Magento Community
 
RulerOfNations
Jr. Member
 
Total Posts:  2
Joined:  2008-07-10
 
dan_w - 10 July 2008 02:14 PM

In previous versions, there wasn’t a “ Add Store Code to Urls”. Now there is though, which can eliminate the need to have different stores in different directories. The option can be turned on/off under configuration->general->web

Wow. Checking that box just saved me hours of work. Incredibly easy. Thanks so much!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

Happy that my suggest has been useful.

Sorry for the late replay, here in Italy was night time.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dormgear
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2008-10-14
Connecticut, USA
 

Seriously, make sure your code is CASE sensitive to your store directory.  I have been pulling my hair out for 30 minutes only to find I accidentally Capitalized two letters in the folder directory!  YIKES!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top