Before writing here, i did lots of research and testings and read too many posts on SO and other blogs, but none fixed my problem. I am developing a website with magento 1.9.2.1. It will have two languages English and Arabic and seven currencies USD, SAR, QAR etc. Lets say the domain is altaf.com ;).
Requirements:
- Website default language will be arabic and default currency will be SAR. So according to this, default url will be ar-sa.altaf.com, where ar is for language and sa is for currency.
- Similarly, en-sa.altaf.com will display english website with SAR currency. Also, ar-us.altaf.com will be used for arabic contents and USD and hence en-us.altaf.com will be used for english contents and USD and so on for other currencies.
How it can be done?
One way to do it as below:
- Create store views for each sub url. So we will have 7 * 2 = 14 store views (according to currencies * languages), and set url in web section for each store view. Also select the appropriate default currency for each store view in Currency Setup section.
- While creating contents for english, select all those store views which will display english contents, and for arabic contents select all those store views which will display arabic contents.
Problems with above:
We have thousands of products and about 20 categories and other lots of contents, which will be hard to manage this way.
While entering data, it is most likely that we will miss to select about 7 store views for each content. Also, it will be more hard to enter data for products.
And some more problems can occur...
How i am doing it?
I created store views and setup appropriate urls for each. For now i only created 4 store views for en-sa.altaf.com, ar-sa.altaf.com, en-us.altaf.com, ar-us.altaf.com
Created sub folders for each store urls like en-sa, en-us, ar-sa and ar-us and placed index.php in it and changed the path to Mage.php accordingly. Made appropriate changes in nginx config files for each domain and set proper root paths. Tested them and confirmed that each sub folder index.php is executed.
Now i am trying to load english contents for each url which has en and arabic contents for each url which has ar. This way, it will be easy to manage all contents. I use
MAGE_RUN_CODE
as en in allindex.php
files which are placed in en-xx sub folders and similarly ar for ar-xx sub folders. I also tried to set store and currency as below for en-us.altaf.com and ar-us.altaf.com which will have usd as currency.
Mage::app()->setCurrentStore('en'); //for en
Mage::app()->getStore()->setCurrentCurrency('usd'); //Set currency for store
and
Mage::app()->setCurrentStore('ar'); //for ar
Mage::app()->getStore()->setCurrentCurrency('usd');
But it does not work, and this is my big problem.
Can any body help me out here to fix this problem or give me details for any other better solution? I will offer a 50 points bounty for a correct answer which solve my problem :).