File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
app/code/Magento/Sales/Model Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments