Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Urldecode problem after adding a product to shopping cart redirect to current page. 
 
sandesh37
Jr. Member
 
Total Posts:  2
Joined:  2013-06-01
 

Hi,

Here is a scenario 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 on in admin panel.

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

All '&' replaced by '&' and it 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

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ravinder
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2013-06-11
 

Hi Sandesh ,

Two ways to fix this:

Way 1:-
---------------------------------------------------------------------------------------------------------------------------
You can just override/rewrite this helper app\code\core\Mage\Core\Helper\Abstract.php

With modification of below function :

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

public function escapeUrl($data)
{
return $data;
}
----------------------------------------------------------------------------------------------------------------
Way 2 (the best way) :
----------------------------------------------------------------------------------------------------------------:
rewrite/override controller /app/code/core/Mage/Core/Controller/Varien/Action.php

with below modified method :

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;
}

To

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;
}
--------------------------------------------------------------------------------------------------------------------------------------
Thanks to the thread http://stackoverflow.com/questions/16891413/urldecode-bug-after-adding-a-simple-product-to-shopping-cart-on-search-page-and grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top