|
| 1 | +diff --git a/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php b/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php |
| 2 | +index 4e47343c3d994..350a47b8facde 100644 |
| 3 | +--- a/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php |
| 4 | ++++ b/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php |
| 5 | +@@ -6,7 +6,7 @@ |
| 6 | + namespace Magento\Sales\Controller\Adminhtml\Order; |
| 7 | + |
| 8 | + use Magento\Framework\App\Action\HttpPostActionInterface; |
| 9 | +-use Magento\Sales\Model\Order; |
| 10 | ++use Magento\Sales\Api\Data\OrderInterface; |
| 11 | + use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender; |
| 12 | + |
| 13 | + /** |
| 14 | +@@ -45,7 +45,7 @@ public function execute() |
| 15 | + throw new \Magento\Framework\Exception\LocalizedException(__($error)); |
| 16 | + } |
| 17 | + |
| 18 | +- $orderStatus = $this->getOrderStatus($order->getDataByKey('status'), $data['status']); |
| 19 | ++ $orderStatus = $this->getOrderStatus($order, $data['status']); |
| 20 | + $order->setStatus($orderStatus); |
| 21 | + $notify = $data['is_customer_notified'] ?? false; |
| 22 | + $visible = $data['is_visible_on_front'] ?? false; |
| 23 | +@@ -85,13 +85,21 @@ public function execute() |
| 24 | + /** |
| 25 | + * Get order status to set |
| 26 | + * |
| 27 | +- * @param string $orderStatus |
| 28 | ++ * @param OrderInterface $order |
| 29 | + * @param string $historyStatus |
| 30 | + * @return string |
| 31 | + */ |
| 32 | +- private function getOrderStatus(string $orderStatus, string $historyStatus): string |
| 33 | ++ private function getOrderStatus(OrderInterface $order, string $historyStatus): string |
| 34 | + { |
| 35 | +- return ($orderStatus === Order::STATE_PROCESSING || $orderStatus === Order::STATUS_FRAUD) ? $historyStatus |
| 36 | +- : $orderStatus; |
| 37 | ++ $config = $order->getConfig(); |
| 38 | ++ if ($config === null) { |
| 39 | ++ return $historyStatus; |
| 40 | ++ } |
| 41 | ++ $statuses = $config->getStateStatuses($order->getState()); |
| 42 | ++ |
| 43 | ++ if (!isset($statuses[$historyStatus])) { |
| 44 | ++ return $order->getDataByKey('status'); |
| 45 | ++ } |
| 46 | ++ return $historyStatus; |
| 47 | + } |
| 48 | + } |
0 commit comments