Skip to content

Commit bfebade

Browse files
committed
MC-38917: Unexpected order cancellation
1 parent cf13b9d commit bfebade

File tree

2 files changed

+9
-13
lines changed
  • app/code/Magento/Sales/Controller/Adminhtml/Order/Create
  • dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create

2 files changed

+9
-13
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function execute()
2323

2424
// Clear existing order in session when creating a new order for a customer
2525
if ($this->getRequest()->getParam('customer_id')) {
26-
$this->clearSessionOrderData();
26+
$this->_getSession()->setOrderId(null);
2727
}
2828

2929
$this->_getOrderCreateModel()->initRuleData();
@@ -34,16 +34,4 @@ public function execute()
3434
$resultPage->getConfig()->getTitle()->prepend(__('New Order'));
3535
return $resultPage;
3636
}
37-
38-
/**
39-
* Clear order data in session
40-
*
41-
* @return $this
42-
*/
43-
private function clearSessionOrderData(): self
44-
{
45-
$this->_getSession()->setOrderId(null);
46-
47-
return $this;
48-
}
4937
}

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/IndexTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ protected function setUp(): void
5252
public function testExecute(): void
5353
{
5454
$customerId = 1;
55+
$editingOrderId = 10;
56+
5557
$this->getRequest()->setMethod(Http::METHOD_GET);
5658
$this->getRequest()->setParam('customer_id', $customerId);
59+
$this->quoteSession->setOrderId($editingOrderId);
60+
$this->assertEquals($editingOrderId, $this->quoteSession->getOrderId());
5761
$this->dispatch('backend/sales/order_create/index');
62+
63+
// Check that existing order in session was cleared
64+
$this->assertEquals(null, $this->quoteSession->getOrderId());
65+
5866
$store = $this->storeManager->getStore();
5967
$this->assertEquals($customerId, $this->quoteSession->getCustomerId());
6068
$ruleData = $this->registry->registry('rule_data');

0 commit comments

Comments
 (0)