0
votes

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:

  1. 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.
  2. 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:

  1. 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.
  2. 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:

  1. We have thousands of products and about 20 categories and other lots of contents, which will be hard to manage this way.

  2. 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.

  3. And some more problems can occur...

How i am doing it?

  1. 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

  2. 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.

  3. 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 all index.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 :).

1

1 Answers

1
votes

If you want to do it in this way you should add 'code' at the name of the php function for setting the currency programatically:

Mage::app()->getStore()->setCurrentCurrencyCode('USD'); 

in place of

Mage::app()->getStore()->setCurrentCurrency('USD');

But I don't think it's the best way though. I would create 2 websites, arabic and english and then add store views for each currency. each website should use same root category. Then set the url's, language and currency for each store view in Magento backend.

When adding a new product all you have to do is insert the content in 2 languages and check 2 checkboxes in the Catalog->Manage products->Product information->Websites.

The currency will apply automatically for each store view.