Skip to content

Fixed Magento reorder order id issue #39399

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

Open
wants to merge 15 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2011 Adobe
* Copyright 2015 Adobe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be 2011 only as the file has been created in 2011 only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* All Rights Reserved.
*/

Expand Down Expand Up @@ -2085,10 +2085,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 @@ -2115,16 +2113,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 Expand Up @@ -2426,3 +2420,4 @@ private function getPaymentMethodSpecifications(): array
return array_values($specifications);
}
}