I am catching the following event to do the further logic:
core_block_abstract_prepare_layout_before
and in the Observer class I am doing this:
Mage::app()->setCurrentStore($storeView);
Mage::run($storeCode, "store");
but this throws an exception:
Mage registry key "application_params" already exists
basically what I am trying to do is "changing the Language (store view) according to the current IP" and I am trying to achieve this through magento custom module.
I want to be able to change the default store view of magento, programmatically using magento event observer? and would it be possible to do so without redirecting to the selected store I mean by setting the values for store view before page load?
Mage::app()->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, $storeCode, TRUE); Mage::app()->setCurrentStore($storeCode); $_baseurl = Mage::getBaseUrl(); echo "<script type='text/javascript'>window.location='{$_baseurl}'</script>";
– R T