工作,當我們打開一個網站:http://ab1.domain.com/Magento的URL不是首次
在瀏覽器中第一次,它會重定向到URL下
http://ab1.domain.com/://index.php/? &給予404未找到1
://index.php/?正在添加爲後綴。但如果我們打開第二次,比它的工作正常。
其多店鋪網站,當我們禁用所有商店也仍然存在問題。
這是自定義模塊的問題,我們使用這個模塊來顯示各個國家的貨幣。
Data.php
<?php
/**
* Atwix
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Atwix Mod
* @package Atwix_Ipstoreswitcher
* @author Atwix Core Team
* @copyright Copyright (c) 2014 Atwix (http://www.atwix.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/* app/code/local/Atwix/Ipstoreswitcher/Helper/Data.php */
class Atwix_Ipstoreswitcher_Helper_Data extends Mage_Core_Helper_Abstract
{
const DEFAULT_STORE = 'India';
/**
* countries to store relation
* default is English
* @var array
*/
protected $_countryToStore = array(
'IN' => 'India',
'US' => 'USA',
'FR' => 'France',
'AR' => 'US dollar [$]',
// 'BO' => 'US dollar [$]'
);
/**
* get store view name by country
* @param $country
* @return bool
*/
public function getStoreByCountry($country)
{
if (isset($this->_countryToStore[$country])) {
return $this->_countryToStore[$country];
}
return self::DEFAULT_STORE;
}
}
的config.xml
<config>
<modules>
<Atwix_Ipstoreswitcher>
<version>1.0.0</version>
</Atwix_Ipstoreswitcher>
</modules>
<global>
<helpers>
<atwix_ipstoreswitcher>
<class>Atwix_Ipstoreswitcher_Helper</class>
</atwix_ipstoreswitcher>
</helpers>
<models>
<atwix_ipstoreswitcher>
<class>Atwix_Ipstoreswitcher_Model</class>
</atwix_ipstoreswitcher>
</models>
</global>
<frontend>
<events>
<controller_action_postdispatch>
<observers>
<atwix_ipstoreswitcher>
<class>atwix_ipstoreswitcher/observer</class>
<method>controllerActionPostdispatch</method>
</atwix_ipstoreswitcher>
</observers>
</controller_action_postdispatch>
</events>
</frontend>
</config>
Observer.php
class Atwix_Ipstoreswitcher_Model_Observer
{
/**
* redirects customer to store view based on GeoIP
* @param $event
*/
public function controllerActionPostdispatch($event)
{
$cookie = Mage::getSingleton('core/cookie');
if ($cookie->get('geoip_processed') != 1) {
$geoIPCountry = Mage::getSingleton('geoip/country');
$countryCode = $geoIPCountry->getCountry();
if ($countryCode) {
$storeName = Mage::helper('atwix_ipstoreswitcher')->getStoreByCountry($countryCode);
if ($storeName) {
$store = Mage::getModel('core/store')->load($storeName, 'name');
if ($store->getName() != Mage::app()->getStore()->getName()) {
$event->getControllerAction()->getResponse()->setRedirect($store->getCurrentUrl(false));
}
}
}
$cookie->set('geoip_processed', '1', time() + 86400, '/');
}
}
}
編輯
我試過的是我替換$store->getCurrentUrl(false)
由Mage::getUrl('*/*/*', array('_use_rewrite' => true, '_forced_secure' => true))
比url問題得到解決。但模塊功能不起作用。
請檢查後端的所有商店URL。 –
@SunnyRathod,但我禁用除主店外的所有商店。,請你指導我在哪裏檢查商店網址? – fresher
'系統>>配置>>網絡>>不安全'和'系統>>配置>>網絡>>安全' 確保您在左上角商店切換器下拉列表中選擇了正確的商店。 –