Skip to content

Commit bce8734

Browse files
committed
magento#38659 - Fix order status update
1 parent be7b88d commit bce8734

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Sales\Controller\Adminhtml\Order;
77

88
use Magento\Framework\App\Action\HttpPostActionInterface;
9-
use Magento\Sales\Model\Order;
9+
use Magento\Sales\Api\Data\OrderInterface;
1010
use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
1111

1212
/**
@@ -45,7 +45,7 @@ public function execute()
4545
throw new \Magento\Framework\Exception\LocalizedException(__($error));
4646
}
4747

48-
$orderStatus = $this->getOrderStatus($order->getDataByKey('status'), $data['status']);
48+
$orderStatus = $this->getOrderStatus($order, $data['status']);
4949
$order->setStatus($orderStatus);
5050
$notify = $data['is_customer_notified'] ?? false;
5151
$visible = $data['is_visible_on_front'] ?? false;
@@ -89,9 +89,13 @@ public function execute()
8989
* @param string $historyStatus
9090
* @return string
9191
*/
92-
private function getOrderStatus(string $orderStatus, string $historyStatus): string
92+
private function getOrderStatus(OrderInterface $order, string $historyStatus): string
9393
{
94-
return ($orderStatus === Order::STATE_PROCESSING || $orderStatus === Order::STATUS_FRAUD) ? $historyStatus
95-
: $orderStatus;
94+
$statuses = $order->getConfig()->getStateStatuses($order->getState());
95+
96+
if (!in_array($historyStatus, array_keys($statuses))) {
97+
return $order->getDataByKey('status');
98+
}
99+
return $historyStatus;
96100
}
97101
}

0 commit comments

Comments
 (0)