From 588ca203ebfd047ab697aa9c41b2f6273d242732 Mon Sep 17 00:00:00 2001 From: vtymchynskyi <vtymchynskyi@ebay.com> Date: Sun, 22 Mar 2015 15:40:11 +0200 Subject: [PATCH] MAGETWO-35385: Fatal error when trying to send notify customer by email about shipment --- .../Adminhtml/Order/Shipment/AddComment.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php index 8e8662624c7..70310d404c6 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php @@ -8,6 +8,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use Magento\Sales\Model\Order\Email\Sender\ShipmentSender; use Magento\Backend\App\Action; +use Magento\Framework\View\Result\LayoutFactory; class AddComment extends \Magento\Backend\App\Action { @@ -21,18 +22,26 @@ class AddComment extends \Magento\Backend\App\Action */ protected $shipmentSender; + /** + * @var LayoutFactory + */ + protected $resultLayoutFactory; + /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader * @param ShipmentSender $shipmentSender + * @param LayoutFactory $resultLayoutFactory */ public function __construct( Action\Context $context, \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, - ShipmentSender $shipmentSender + ShipmentSender $shipmentSender, + LayoutFactory $resultLayoutFactory ) { $this->shipmentLoader = $shipmentLoader; $this->shipmentSender = $shipmentSender; + $this->resultLayoutFactory = $resultLayoutFactory; parent::__construct($context); } @@ -72,10 +81,9 @@ class AddComment extends \Magento\Backend\App\Action $this->shipmentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']); $shipment->save(); - - $this->_view->loadLayout(false); - $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Shipments')); - $response = $this->_view->getLayout()->getBlock('shipment_comments')->toHtml(); + $resultLayout = $this->resultLayoutFactory->create(); + $resultLayout->addDefaultHandle(); + $response = $resultLayout->getLayout()->getBlock('shipment_comments')->toHtml(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $response = ['error' => true, 'message' => $e->getMessage()]; } catch (\Exception $e) { -- GitLab