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