1

Here is a scenario with Magento CE 1.7.0.2 If you are on catalog search page and list mode is on.

Url:  http://127.0.0.1/magento/catalogsearch/result/index/?mode=list&q=the

And redirect to current page after adding product to cart is Active in admin panel.

If you try to add simple product to cart, product added to cart successful but redirection URL is not decoded properly

All ‘&’ replaced by ‘&’ and result in breaking search result...

Result URL: http://127.0.0.1/magento/catalogsearch/result/index/?mode=list&q=the

I think this bug may be already attended but I don’t find any topic on it....

Kindly help in this

Thanks in advance

4

2 回答 2

0

感谢 Mufaddal 提供参考。我有两种简单的方法来解决这个问题:

方式1:-

您可以覆盖/重写此帮助程序 app\code\core\Mage\Core\Helper\Abstract.php

通过修改以下功能:

public function escapeUrl($data) 
{ 
return htmlspecialchars($data); 
} 

public function escapeUrl($data) 
{ 
return $data; 
} 

方式2(最好的方式):

重写/覆盖控制器/app/code/core/Mage/Core/Controller/Varien/Action.php

使用以下修改方法:

protected function _getRefererUrl() 
{ 
$refererUrl = $this->getRequest()->getServer(’HTTP_REFERER’); 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL)) { 
$refererUrl = $url; 
} 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL)) { 
$refererUrl = Mage::helper(’core’)->urlDecode($url); 
} 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) { 
$refererUrl = Mage::helper(’core’)->urlDecode($url); 
}

$refererUrl = Mage::helper(’core’)->escapeUrl($refererUrl);

if (!$this->_isUrlInternal($refererUrl)) { 
$refererUrl = Mage::app()->getStore()->getBaseUrl(); 
} 
return $refererUrl; 
}

protected function _getRefererUrl() 
{ 
$refererUrl = $this->getRequest()->getServer(’HTTP_REFERER’); 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL)) { 
$refererUrl = $url; 
} 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL)) { 
$refererUrl = Mage::helper(’core’)->urlDecode($url); 
} 
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) { 
$refererUrl = Mage::helper(’core’)->urlDecode($url); 
}

//$refererUrl = Mage::helper(’core’)->escapeUrl($refererUrl);

if (!$this->_isUrlInternal($refererUrl)) { 
$refererUrl = Mage::app()->getStore()->getBaseUrl(); 
} 
return $refererUrl; 
} 
于 2013-07-31T05:53:46.267 回答
0

在这个文件 app\code\core\Mage\Core\Helper\Abstract.php public function escapeUrl($data) 中,这个函数负责奇怪的 url。

它使用htmlspecialcharsphp 的函数替换&'&'见这里http://php.net/manual/en/function.htmlspecialchars.php

所以我要做的是$this->getResponse()->setRedirect($returnUrl);在我的 CartController_goBack方法中评论这一行,而不是我使用了我的自定义重定向方法。

于 2013-06-03T12:13:56.550 回答