Skip to content

Commit 588ca20

Browse files
author
vtymchynskyi
committed
MAGETWO-35385: Fatal error when trying to send notify customer by email about shipment
1 parent 7f98433 commit 588ca20

File tree

1 file changed

+13
-5
lines changed
  • app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment

1 file changed

+13
-5
lines changed

app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Sales\Model\Order\Email\Sender\ShipmentSender;
1010
use Magento\Backend\App\Action;
11+
use Magento\Framework\View\Result\LayoutFactory;
1112

1213
class AddComment extends \Magento\Backend\App\Action
1314
{
@@ -21,18 +22,26 @@ class AddComment extends \Magento\Backend\App\Action
2122
*/
2223
protected $shipmentSender;
2324

25+
/**
26+
* @var LayoutFactory
27+
*/
28+
protected $resultLayoutFactory;
29+
2430
/**
2531
* @param Action\Context $context
2632
* @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader
2733
* @param ShipmentSender $shipmentSender
34+
* @param LayoutFactory $resultLayoutFactory
2835
*/
2936
public function __construct(
3037
Action\Context $context,
3138
\Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader,
32-
ShipmentSender $shipmentSender
39+
ShipmentSender $shipmentSender,
40+
LayoutFactory $resultLayoutFactory
3341
) {
3442
$this->shipmentLoader = $shipmentLoader;
3543
$this->shipmentSender = $shipmentSender;
44+
$this->resultLayoutFactory = $resultLayoutFactory;
3645
parent::__construct($context);
3746
}
3847

@@ -72,10 +81,9 @@ public function execute()
7281

7382
$this->shipmentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']);
7483
$shipment->save();
75-
76-
$this->_view->loadLayout(false);
77-
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Shipments'));
78-
$response = $this->_view->getLayout()->getBlock('shipment_comments')->toHtml();
84+
$resultLayout = $this->resultLayoutFactory->create();
85+
$resultLayout->addDefaultHandle();
86+
$response = $resultLayout->getLayout()->getBlock('shipment_comments')->toHtml();
7987
} catch (\Magento\Framework\Exception\LocalizedException $e) {
8088
$response = ['error' => true, 'message' => $e->getMessage()];
8189
} catch (\Exception $e) {

0 commit comments

Comments
 (0)