Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Hold.php
Go to the documentation of this file.
1 <?php
7 
9 {
15  const ADMIN_RESOURCE = 'Magento_Sales::hold';
16 
22  public function execute()
23  {
24  $resultRedirect = $this->resultRedirectFactory->create();
25  if (!$this->isValidPostRequest()) {
26  $this->messageManager->addErrorMessage(__('You have not put the order on hold.'));
27  return $resultRedirect->setPath('sales/*/');
28  }
29  $order = $this->_initOrder();
30  if ($order) {
31  try {
32  $this->orderManagement->hold($order->getEntityId());
33  $this->messageManager->addSuccessMessage(__('You put the order on hold.'));
34  } catch (\Magento\Framework\Exception\LocalizedException $e) {
35  $this->messageManager->addErrorMessage($e->getMessage());
36  } catch (\Exception $e) {
37  $this->messageManager->addErrorMessage(__('You have not put the order on hold.'));
38  }
39  $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
40  return $resultRedirect;
41  }
42  $resultRedirect->setPath('sales/*/');
43  return $resultRedirect;
44  }
45 }
$order
Definition: order.php:55
__()
Definition: __.php:13