From 332a06c0f0bda654287ab16ff0071b8de7632ef1 Mon Sep 17 00:00:00 2001 From: Kuba Date: Thu, 22 Nov 2012 15:48:11 +0100 Subject: [PATCH 1/2] Fixed deleting of products in sidebar cart, compare and wishlist --- code/controllers/CallController.php | 6 +++++- code/etc/config.xml | 5 +++++ frontend/template/aoestatic/beforebodyend.phtml | 1 + js/aoestatic/common.js | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/code/controllers/CallController.php b/code/controllers/CallController.php index c790a0c..2bf9372 100644 --- a/code/controllers/CallController.php +++ b/code/controllers/CallController.php @@ -19,6 +19,8 @@ class Aoe_Static_CallController extends Mage_Core_Controller_Front_Action { public function indexAction() { // if (!$this->getRequest()->isXmlHttpRequest()) { Mage::throwException('This is not an XmlHttpRequest'); } + $returnUrl = $this->getRequest()->getParam('returnUrl'); + Mage::getSingleton('core/session')->setReturnUrl($returnUrl); $response = array(); $response['sid'] = Mage::getModel('core/session')->getEncryptedSessionId(); @@ -41,7 +43,9 @@ public function indexAction() { } } } - $this->getResponse()->setBody(Zend_Json::encode($response)); + Mage::getSingleton('core/session')->unsReturnUrl(); + + $this->getResponse()->setBody(Zend_Json::encode($response)); } } diff --git a/code/etc/config.xml b/code/etc/config.xml index bacc0e7..39a5455 100644 --- a/code/etc/config.xml +++ b/code/etc/config.xml @@ -24,6 +24,11 @@ Aoe_Static_Helper + + + Aoe_Static_Helper_Url + + diff --git a/frontend/template/aoestatic/beforebodyend.phtml b/frontend/template/aoestatic/beforebodyend.phtml index 807e44d..8585730 100644 --- a/frontend/template/aoestatic/beforebodyend.phtml +++ b/frontend/template/aoestatic/beforebodyend.phtml @@ -6,5 +6,6 @@ var CURRENTPRODUCTID = 'getId() ?>'; var CUSTOMERNAME = 'getCustomerName() ?>'; var CARTSUMMARYCOUNT = 'getCartSummaryCount(); ?>'; + var RETURNURL = 'helper('core/url')->getCurrentUrl() ?>'; //]]> diff --git a/js/aoestatic/common.js b/js/aoestatic/common.js index 0bd401c..b289a38 100755 --- a/js/aoestatic/common.js +++ b/js/aoestatic/common.js @@ -34,6 +34,7 @@ jQuery(document).ready(function($) { data.currentProductId = CURRENTPRODUCTID; } + data.returnUrl = RETURNURL; // E.T. phone home if (typeof data.currentProductId !== 'undefined' || counter > 0) { $.get( From 3ebfa7be782d5fbe16b32b4cd124486e53909668 Mon Sep 17 00:00:00 2001 From: Kuba Date: Thu, 22 Nov 2012 15:48:11 +0100 Subject: [PATCH 2/2] Fixed deleting of products in sidebar cart, compare and wishlist --- code/Helper/Url.php | 23 +++++++++++++++++++ code/controllers/CallController.php | 6 ++++- code/etc/config.xml | 5 ++++ .../template/aoestatic/beforebodyend.phtml | 1 + js/aoestatic/common.js | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 code/Helper/Url.php diff --git a/code/Helper/Url.php b/code/Helper/Url.php new file mode 100644 index 0000000..d14e5a3 --- /dev/null +++ b/code/Helper/Url.php @@ -0,0 +1,23 @@ + + */ +class Aoe_Static_Helper_Url extends Mage_Core_Helper_Url +{ + public function getEncodedUrl($url=null) + { + $sessionUrl = Mage::getSingleton('core/session')->getReturnUrl(); + if ($sessionUrl != NULL) { + return $this->urlEncode($sessionUrl); + } + if (!$url) { + $url = $this->getCurrentUrl(); + } + return $this->urlEncode($url); + } +} \ No newline at end of file diff --git a/code/controllers/CallController.php b/code/controllers/CallController.php index c790a0c..2bf9372 100644 --- a/code/controllers/CallController.php +++ b/code/controllers/CallController.php @@ -19,6 +19,8 @@ class Aoe_Static_CallController extends Mage_Core_Controller_Front_Action { public function indexAction() { // if (!$this->getRequest()->isXmlHttpRequest()) { Mage::throwException('This is not an XmlHttpRequest'); } + $returnUrl = $this->getRequest()->getParam('returnUrl'); + Mage::getSingleton('core/session')->setReturnUrl($returnUrl); $response = array(); $response['sid'] = Mage::getModel('core/session')->getEncryptedSessionId(); @@ -41,7 +43,9 @@ public function indexAction() { } } } - $this->getResponse()->setBody(Zend_Json::encode($response)); + Mage::getSingleton('core/session')->unsReturnUrl(); + + $this->getResponse()->setBody(Zend_Json::encode($response)); } } diff --git a/code/etc/config.xml b/code/etc/config.xml index bacc0e7..39a5455 100644 --- a/code/etc/config.xml +++ b/code/etc/config.xml @@ -24,6 +24,11 @@ Aoe_Static_Helper + + + Aoe_Static_Helper_Url + + diff --git a/frontend/template/aoestatic/beforebodyend.phtml b/frontend/template/aoestatic/beforebodyend.phtml index 807e44d..8585730 100644 --- a/frontend/template/aoestatic/beforebodyend.phtml +++ b/frontend/template/aoestatic/beforebodyend.phtml @@ -6,5 +6,6 @@ var CURRENTPRODUCTID = 'getId() ?>'; var CUSTOMERNAME = 'getCustomerName() ?>'; var CARTSUMMARYCOUNT = 'getCartSummaryCount(); ?>'; + var RETURNURL = 'helper('core/url')->getCurrentUrl() ?>'; //]]> diff --git a/js/aoestatic/common.js b/js/aoestatic/common.js index 0bd401c..b289a38 100755 --- a/js/aoestatic/common.js +++ b/js/aoestatic/common.js @@ -34,6 +34,7 @@ jQuery(document).ready(function($) { data.currentProductId = CURRENTPRODUCTID; } + data.returnUrl = RETURNURL; // E.T. phone home if (typeof data.currentProductId !== 'undefined' || counter > 0) { $.get(