From 241d4d53425b8a3bc4704bcd713808ebe85361f2 Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Sun, 6 Nov 2022 16:15:43 +0100 Subject: [PATCH 1/2] Do not crash when creditmemo does not exist --- .../controllers/Sales/Order/CreditmemoController.php | 4 ++++ app/locale/en_US/Mage_Adminhtml.csv | 1 + 2 files changed, 5 insertions(+) diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index f9015592179..ac8c353c2cd 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -101,6 +101,10 @@ protected function _initCreditmemo($update = false) $orderId = $this->getRequest()->getParam('order_id'); if ($creditmemoId) { $creditmemo = Mage::getModel('sales/order_creditmemo')->load($creditmemoId); + if (!$creditmemo->getId()) { + $this->_getSession()->addError($this->__('The credit memo no longer exists.')); + return false; + } } elseif ($orderId) { $data = $this->getRequest()->getParam('creditmemo'); $order = Mage::getModel('sales/order')->load($orderId); diff --git a/app/locale/en_US/Mage_Adminhtml.csv b/app/locale/en_US/Mage_Adminhtml.csv index 3ac9e6536a9..b94940befda 100644 --- a/app/locale/en_US/Mage_Adminhtml.csv +++ b/app/locale/en_US/Mage_Adminhtml.csv @@ -205,6 +205,7 @@ "Cannot add tracking number.","Cannot add tracking number." "Cannot create an invoice without products.","Cannot create an invoice without products." "Cannot create credit memo for the order.","Cannot create credit memo for the order." +"The credit memo no longer exists.","The credit memo no longer exists." "Cannot delete the design change.","Cannot delete the design change." "Cannot delete tracking number.","Cannot delete tracking number." "Cannot do shipment for the order separately from invoice.","Cannot do shipment for the order separately from invoice." From b2c535219aec552ef8410be72d1399848809ec3f Mon Sep 17 00:00:00 2001 From: Ng Kiat Siong Date: Mon, 7 Nov 2022 09:46:21 +0800 Subject: [PATCH 2/2] Redirect to grid if credit memo does not exist --- .../Adminhtml/controllers/Sales/Order/CreditmemoController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index ac8c353c2cd..6630d3f45dc 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -197,7 +197,7 @@ public function viewAction() $this->_setActiveMenu('sales/order') ->renderLayout(); } else { - $this->_forward('noRoute'); + $this->_redirect('*/*'); } }