Magento Multi store setup sub folders
Okay so I tried to create a multistore magento setup on a single domein using subfolders.
The internet is stuffed with posts and topics about this. After a long while I figured out what worked for me. I hope this can help anyone having the same issue’s as me.
First, what am I using?
- Magento 1.5.0.1
- Xampp v1.8
What do I want to do ?
Create several stores in subfolders of the main magento store. That are all separate from eachother, skin, products, customers.
How did I do this?
I assume you have a magento install running on your server, or xampp so I won’t go into that. Aswell as have the knownledge to organize products.
There are 5 main steps to complete this:
1. Create stores/views/sites
2. Create categories & add products
3. Set default URL (safe/unsafe) and Homepage.
4. Create subfolders and files
5. Edit index.php in each subfolder
1. Create stores/views/sites
Goto >system> configuration > manage stores
Add a new Website for each subfolder store you want, after the website make a store and a store view for the subfolder store.
So it looks mywebsite > mystore > mystoreview, and remember the “Code” you enter we will need it later on.
2. Create categories & add products
Goto>Catalogue>Manage categories
Add a new root category for each of your subfolder stores, enable it, and set it to Anchor>Yes
Now you can create another sub category which will contain the products shown ONLY to visitors of that subfolder store.
But, to make the products visible you will first need to change your storeview before we can add products to the category.
So change the storeview in the left column and add products to your category
Note: For the products to become usable in the category list they need to be set to the correct store view aswell. This can be done by updating the products attributes in Catalogue>Manage products>update attributes>Websites
3. Set default URL (safe/unsafe) and Homepage.
Goto>System>Configuration>Web
Change Secure and insecure for each scope so it looks like this. NOTE that the skin,media and js url do not have the sub folder reference. Keep it that way !
Change the CMS Homepage in defaultpages, or goto>CMS>Homepage and change the scope of an already existing page, so we can use it on this view.
If you do not do this you will get a “There was no Home CMS page configured or found”
4. Create subfolders and files
Browse to the homefolder of your magento installation. Create new folders that correspond with the subfolder stores we made earlier.
Copy the .htaccess and Index.php from the main folder to these subfolders.
5. Edit index.php in each subfolder
Open index.php and replace these lines:
/* 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(‘mycode’, ‘website’); //(for me: Mage::run(‘kbc’, ‘website’);)
Okay so this was my notebook for this problem. Note that if you don’t see any products, that you are sure you alterd the right products in the right product scopes.
And ALWAYS disable your cache during development. Have a nice day.
Last Updated (Saturday, 27 October 2012 20:39)
Hay que buscar la línea que dice:
$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
Comentarla o modificarla por:
$compilerConfig = '../includes/config.php';
---
Hay que buscar también la línea que dice:
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
Comentarla o modificarla por:
$mageFilename = '../app/Mage.php';
Saludos desde Colombia.
$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
to:
$compilerConfig = '../includes/config.php';
but I can't access the sites as I get the error: "app/Mage.php was not found".
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
You need to change the path to the Mage.php file so that it points to the file in your Magento installation. Assuming that your Magento is installed directly in the pubic_html folder on your account, you need to edit the code so that it looks like this:
$mageFilename = '/home/username/public_html/app/Mage.php';
This would be the full path on your account to the Mage.php file. Of course, you need to change username with your actual username.
when i install magento below error occur, i cant do anything what can i do...
Check this advance multi store setup extension released by FME.
By using this extension you can easily create multiple store and configure them for specific locations, regions, or countries.
http://www.fmeextensions.com/magento-geo-ip-default-store-view.html
Customers are automatically redirected to the appropriate store based on their IP-address.
www.website.com/sub1 www.website.com/sub2 www.website.com/sub3
The server used is ngnix. everything is set up. And used to work, the nginx conf file for this site need to be reconstructed.
at the moment when for example www.website.com/sub1 is requested this wil set the store to store to sub1. which works fine. However when a product is asked i.e. www.website.com/sub1/product this returned a "page not found" error.
If the store is set to sub1 the url www.website.com/product DOES FIND the product without any issues. on the other hand f the store was not set previously, www.website.com/product DID NOT FIND the product.
it seemed that once a store is set the following happens e.g. www.website.com/sub1/product :
sub1->sub1->product == error (because of sub1->sub1)
this should be:
sub1->product.
note that setting the store when www.website.com/sub1/product is requested and then redirecting the site to www.website.com/product is not an option. everything used to work fine! The store setup had not been changed. only the the nginx conf file should be adjusted. any sugestions?