Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento - How I can Run Store by Country by GeoIP?
    primarykey
    data
    text
    <p>I want run store by IP of the customer.</p> <p>In the backend of Magento, the user may configure the concret Store to load per country. </p> <p>Taking a glance, I see the method at class Mage_Core_Model_App</p> <pre><code>public function run($params) { $options = isset($params['options']) ? $params['options'] : array(); $this-&gt;baseInit($options); if ($this-&gt;_cache-&gt;processRequest()) { $this-&gt;getResponse()-&gt;sendResponse(); } else { $this-&gt;_initModules(); $this-&gt;loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); if ($this-&gt;_config-&gt;isLocalConfigLoaded()) { //$scopeCode = isset($params['scope_code']) ? $params['scope_code'] : ''; //===============custom scope by country====================== $scopeCode = Mage::helper('custom/module')-&gt;getStoreByGeoip(); //===============custom scope by country====================== $scopeType = isset($params['scope_type']) ? $params['scope_type'] : 'store'; $this-&gt;_initCurrentStore($scopeCode, $scopeType); $this-&gt;_initRequest(); Mage_Core_Model_Resource_Setup::applyAllDataUpdates(); } $this-&gt;getFrontController()-&gt;dispatch(); } return $this; } </code></pre> <p>In my progress to get a good solution, I thought another alternative.</p> <p>In the index.php write the next code:</p> <pre><code> Mage::app(); Mage::Helper('custom/helper')-&gt;getRunCodeByGeoio(); Mage::run($mageRunCode, $mageRunType); </code></pre> <p>I thinks this haven´t dangerous of performance because this method only create object if you not have before</p> <pre><code>/** * Get initialized application object. * * @param string $code * @param string $type * @param string|array $options * @return Mage_Core_Model_App */ public static function app($code = '', $type = 'store', $options = array()) { if (null === self::$_app) { self::$_app = new Mage_Core_Model_App(); self::setRoot(); self::$_events = new Varien_Event_Collection(); self::$_config = new Mage_Core_Model_Config(); Varien_Profiler::start('self::app::init'); self::$_app-&gt;init($code, $type, $options); Varien_Profiler::stop('self::app::init'); self::$_app-&gt;loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); } return self::$_app; } </code></pre> <p>And my question is......</p> <p>Are this the best approach for get the solution??</p> <p>I think is very dangerous modify Mage_Core_Model_App even using rewrite</p> <p>I don´t have any event at tier</p> <p>Another option is made the business in the index.php but lost the management by the backend</p> <p>Searching...., found a extension that cover many of my requirements, <a href="http://www.mageworx.com/store-and-currency-auto-switcher-magento-extension.html" rel="nofollow">http://www.mageworx.com/store-and-currency-auto-switcher-magento-extension.html</a> then I'll buy this or made a similar extension.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload