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
198
198
/**
199
199
* @var \Magento\Catalog\Api\ProductRepositoryInterface
200
200
* @deprecated 100.1.0 Remove unused dependency.
201
+ * @see no alternative
201
202
*/
202
203
protected $ productRepository ;
203
204
@@ -1741,7 +1742,17 @@ public function getStatusHistoryById($statusId)
1741
1742
public function addStatusHistory (\Magento \Sales \Model \Order \Status \History $ history )
1742
1743
{
1743
1744
$ 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
+ }
1745
1756
if (!$ history ->getId ()) {
1746
1757
$ this ->setStatusHistories (array_merge ($ this ->getStatusHistories (), [$ history ]));
1747
1758
$ this ->setDataChanges (true );
You can’t perform that action at this time.
0 commit comments