Skip to content

Commit aa01106

Browse files
committed
Merge remote-tracking branch 'origin/AC-1342' into Arrows_2.4.7_Backlog_Delivery
2 parents c766d6c + 1af701f commit aa01106

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/code/Magento/Sales/Model/Order.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface
198198
/**
199199
* @var \Magento\Catalog\Api\ProductRepositoryInterface
200200
* @deprecated 100.1.0 Remove unused dependency.
201+
* @see no alternative
201202
*/
202203
protected $productRepository;
203204

@@ -1741,7 +1742,17 @@ public function getStatusHistoryById($statusId)
17411742
public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $history)
17421743
{
17431744
$history->setOrder($this);
1744-
$this->setStatus($history->getStatus());
1745+
if (!$history->getStatus()) {
1746+
$previousStatus = $this->getStatusHistoryCollection()->getFirstItem()->getData('status');
1747+
if (!$previousStatus) {
1748+
$defaultStatus = $this->getConfig()->getStateDefaultStatus($this->getState());
1749+
$history->setStatus($defaultStatus);
1750+
} else {
1751+
$history->setStatus($previousStatus);
1752+
}
1753+
} else {
1754+
$this->setStatus($history->getStatus());
1755+
}
17451756
if (!$history->getId()) {
17461757
$this->setStatusHistories(array_merge($this->getStatusHistories(), [$history]));
17471758
$this->setDataChanges(true);

0 commit comments

Comments
 (0)