Skip to content

Commit

Permalink
Implemented MAGETWO-11122: Configurable Grids (magento#471)
Browse files Browse the repository at this point in the history
- refactored class Magento\Backend\App\Action\Order - made all actions consistent, removed obsolete actions
  • Loading branch information
Zyava committed Feb 1, 2014
1 parent d111a7c commit 185611d
Showing 1 changed file with 44 additions and 47 deletions.
91 changes: 44 additions & 47 deletions app/code/Magento/Sales/Controller/Adminhtml/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public function viewAction()
}
$this->_title->add(sprintf("#%s", $order->getRealOrderId()));
$this->_view->renderLayout();
} else {
$this->_forward('noroute');
}
}

Expand All @@ -181,8 +183,10 @@ public function emailAction()
$this->messageManager->addError(__('We couldn\'t send the email order.'));
$this->_objectManager->get('Magento\Logger')->logException($e);
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
} else {
$this->_forward('noroute');
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
}

/**
Expand All @@ -205,6 +209,8 @@ public function cancelAction()
$this->_objectManager->get('Magento\Logger')->logException($e);
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
} else {
$this->_forward('noroute');
}
}

Expand All @@ -227,6 +233,8 @@ public function holdAction()
$this->messageManager->addError(__('You have not put the order on hold.'));
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
} else {
$this->_forward('noroute');
}
}

Expand All @@ -249,6 +257,8 @@ public function unholdAction()
$this->messageManager->addError(__('The order was not on hold.'));
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
} else {
$this->_forward('noroute');
}
}

Expand All @@ -259,38 +269,39 @@ public function unholdAction()
*/
public function reviewPaymentAction()
{
try {
$order = $this->_initOrder();
if (!$order) {
return;
}
$action = $this->getRequest()->getParam('action', '');
switch ($action) {
case 'accept':
$order->getPayment()->accept();
$message = __('The payment has been accepted.');
break;
case 'deny':
$order->getPayment()->deny();
$message = __('The payment has been denied.');
break;
case 'update':
$order->getPayment()
->registerPaymentReviewAction(\Magento\Sales\Model\Order\Payment::REVIEW_ACTION_UPDATE, true);
$message = __('The payment update has been made.');
break;
default:
throw new \Exception(sprintf('Action "%s" is not supported.', $action));
$order = $this->_initOrder();
if ($order) {
try {
$action = $this->getRequest()->getParam('action', '');
switch ($action) {
case 'accept':
$order->getPayment()->accept();
$message = __('The payment has been accepted.');
break;
case 'deny':
$order->getPayment()->deny();
$message = __('The payment has been denied.');
break;
case 'update':
$order->getPayment()
->registerPaymentReviewAction(\Magento\Sales\Model\Order\Payment::REVIEW_ACTION_UPDATE, true);
$message = __('The payment update has been made.');
break;
default:
throw new \Exception(sprintf('Action "%s" is not supported.', $action));
}
$order->save();
$this->messageManager->addSuccess($message);
} catch (\Magento\Core\Exception $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We couldn\'t update the payment.'));
$this->_objectManager->get('Magento\Logger')->logException($e);
}
$order->save();
$this->messageManager->addSuccess($message);
} catch (\Magento\Core\Exception $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We couldn\'t update the payment.'));
$this->_objectManager->get('Magento\Logger')->logException($e);
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
} else {
$this->_forward('noroute');
}
$this->_redirect('sales/order/view', array('order_id' => $order->getId()));
}

/**
Expand Down Expand Up @@ -337,6 +348,8 @@ public function addCommentAction()
$response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response);
$this->getResponse()->setBody($response);
}
} else {
$this->_forward('noroute');
}
}

Expand Down Expand Up @@ -487,22 +500,6 @@ public function massUnholdAction()
$this->_redirect('sales/*/');
}

/**
* Change status for selected orders
*/
public function massStatusAction()
{

}

/**
* Print documents for selected orders
*/
public function massPrintAction()
{

}

/**
* Print invoices for selected orders
*/
Expand Down

0 comments on commit 185611d

Please sign in to comment.