How do I programmatically set the locale information of a store view?

enter image description here

I don't know how to set this value, although I can get it using:

echo Mage::getStoreConfig('general/locale/code', $store_view->getId()) ;

Here it follows the code I use to programmatically create the store view:

$store_view = Mage::getModel('core/store');

Try this

Mage::getModel('core/config')->saveConfig('general/locale/code', $value, $scope, $scopeId);

See function definition of saveConfig() at \app\code\core\Mage\Core\Model\Config.php

| improve this answer | |
  • 1
    Thank you so much, this is the code I used: Mage::getModel('core/config')->saveConfig('general/locale/code', "en_US", "stores", $english_store->getId()); – Niko Zarzani Aug 1 '16 at 10:53

Please use below code to set locale value. and write second line for clear cache.


Please specify store ID if you have multi store.

| improve this answer | |

You can set Direct Language code

$locale = 'nl_NL';
$locale = Mage::getSingleton('core/session')->getMyLang();

Mage::getSingleton('core/translate')->setLocale($locale)->init('frontend', true);

$defaultStore = Mage::app()->getStore()->getCode();
Mage::app()->getTranslator()->init('frontend', true);

$defaultLocale = Mage::app()->getLocale()->getLocaleCode();

now Site translate in Your set Language.

you can pass $locale value dynamically on dropdown change event using js.

| improve this answer | |

Try this one,

$config = new Mage_Core_Model_Config();
$config -> saveConfig('general/locale/code', $value , 'default', $storeId);
| improve this answer | |
  • 1
    $config = new Mage_Core_Model_Config(); .. this is not the best way of coding .. you should use Mage::getModel('core/config') instead.. – Reena Parekh Jul 29 '16 at 11:57
  • Oh thanx for the information... But this is also working for me. – Dhrumin Jul 29 '16 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.