我想通过客户的IP来运行存储。Magento - 我如何通过GeoIP按国家/地区运行商店?
在Magento的后端,用户可以配置混合存储以在每个国家加载。
以一眼,我看到该方法在类Mage_Core_Model_App
public function run($params)
{
$options = isset($params['options']) ? $params['options'] : array();
$this->baseInit($options);
if ($this->_cache->processRequest()) {
$this->getResponse()->sendResponse();
} else {
$this->_initModules();
$this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
if ($this->_config->isLocalConfigLoaded()) {
//$scopeCode = isset($params['scope_code']) ? $params['scope_code'] : '';
//===============custom scope by country======================
$scopeCode = Mage::helper('custom/module')->getStoreByGeoip();
//===============custom scope by country======================
$scopeType = isset($params['scope_type']) ? $params['scope_type'] : 'store';
$this->_initCurrentStore($scopeCode, $scopeType);
$this->_initRequest();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
$this->getFrontController()->dispatch();
}
return $this;
}
在我的进步得到了很好的解决,我想另一种选择。
在index.php写下面的代码:
Mage::app();
Mage::Helper('custom/helper')->getRunCodeByGeoio();
Mage::run($mageRunCode, $mageRunType);
我认为这haven't危险的性能,因为这种方法只创建对象,如果你没有以前
/**
* 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->init($code, $type, $options);
Varien_Profiler::stop('self::app::init');
self::$_app->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
}
return self::$_app;
}
和我问题是......
这是获得解决方案的最佳方法吗?
,我认为是非常危险的修改甚至重写使用Mage_Core_Model_App
我不必须在层中的任何事件
另一种选择是由企业在index.php而是由后端
失去了管理正在搜索......,找到了一个扩展程序,涵盖了我的许多要求, http://www.mageworx.com/store-and-currency-auto-switcher-magento-extension.html 然后我会购买这个或做了类似的扩展。
我已经被分配了相同的任务,并试图寻找这样的事件,可以帮助我做到这一点,但我能够实现的唯一方法是(在通过访客ip获取[整个过程]国家后)重定向到特定(分配)的商店。 –
这个模块可以帮助你http://www.mageworx.com/store-and-currency-auto-switcher-magento-extension.html – davidselo