Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Magento reorder order id issue #39399

Open
wants to merge 11 commits into
base: 2.4-develop
Choose a base branch
from
12 changes: 3 additions & 9 deletions app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -2091,10 +2091,8 @@ public function createOrder()
private function beforeSubmit(Quote $quote)
{
$orderData = [];
if ($this->getSession()->getReordered() || $this->getSession()->getOrder()->getId()) {
if ($this->getSession()->getOrder()->getId()) {
$oldOrder = $this->getSession()->getOrder();
$oldOrder = $oldOrder->getId() ?
$oldOrder : $this->orderRepositoryInterface->get($this->getSession()->getReordered());
$originalId = $oldOrder->getOriginalIncrementId();
if (!$originalId) {
$originalId = $oldOrder->getIncrementId();
Expand All @@ -2121,16 +2119,12 @@ private function beforeSubmit(Quote $quote)
*/
private function afterSubmit(Order $order)
{
if ($this->getSession()->getReordered() || $this->getSession()->getOrder()->getId()) {
if ($this->getSession()->getOrder()->getId()) {
$oldOrder = $this->getSession()->getOrder();
$oldOrder = $oldOrder->getId() ?
$oldOrder : $this->orderRepositoryInterface->get($this->getSession()->getReordered());
$oldOrder->setRelationChildId($order->getId());
$oldOrder->setRelationChildRealId($order->getIncrementId());
$oldOrder->save();
if ($this->getSession()->getOrder()->getId()) {
$this->orderManagement->cancel($oldOrder->getEntityId());
}
$this->orderManagement->cancel($oldOrder->getEntityId());
$order->save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ protected function setUp(): void

$this->orderMock = $this->getMockBuilder(Order::class)
->disableOriginalConstructor()
->addMethods(['setReordered', 'getReordered'])
->onlyMethods(
[
'getEntityId',
Expand Down Expand Up @@ -505,8 +504,6 @@ public function testInitFromOrder()

$this->orderMock->method('getItemsCollection')
->willReturn($itemCollectionMock);
$this->orderMock->method('getReordered')
->willReturn(false);
$this->orderMock->method('getShippingAddress')
->willReturn($address);
$this->orderMock->method('getBillingAddress')
Expand Down