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

v2.4.7-p1 Magento reorder -1 order numbers #39089

Open
5 tasks
sgeleon opened this issue Aug 22, 2024 · 12 comments · May be fixed by #39399
Open
5 tasks

v2.4.7-p1 Magento reorder -1 order numbers #39089

sgeleon opened this issue Aug 22, 2024 · 12 comments · May be fixed by #39399
Assignees
Labels
Area: Order Component: Order grid Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.7 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@sgeleon
Copy link

sgeleon commented Aug 22, 2024

Preconditions and environment

  • Magento version - 2.4.7

Steps to reproduce

  1. Open any order
  2. Click reorder
  3. Submit the order

Expected result

The order number is unique 8 digits.

Actual result

The order number is the same 8 digits as the previous order with “-1” added to the end.

Additional information

Early before version 2.4.7, when we recreated an order, you would get a new unique number. In version 2.4.7, you get a number with the postfix '-1' added to the end. This appeared after the bug fix. [Sales] Missing relation data when reorder.

To fix this behavior, I suggest the following:

Index: vendor/magento/module-sales/Model/AdminOrder/Create.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/module-sales/Model/AdminOrder/Create.php b/vendor/magento/module-sales/Model/AdminOrder/Create.php
--- a/vendor/magento/module-sales/Model/AdminOrder/Create.php	
+++ b/vendor/magento/module-sales/Model/AdminOrder/Create.php	(date 1724315876294)
@@ -2056,10 +2056,13 @@
                 'original_increment_id' => $originalId,
                 'relation_parent_id' => $oldOrder->getId(),
                 'relation_parent_real_id' => $oldOrder->getIncrementId(),
-                'edit_increment' => $oldOrder->getEditIncrement() + 1,
-                'increment_id' => $originalId . '-' . ($oldOrder->getEditIncrement() + 1)
+                'edit_increment' => $oldOrder->getEditIncrement() + 1
             ];
-            $quote->setReservedOrderId($orderData['increment_id']);
+
+            if($this->getSession()->getOrder()->getId()) {
+                $orderData['increment_id'] = $originalId . '-' . ($oldOrder->getEditIncrement() + 1);
+                $quote->setReservedOrderId($orderData['increment_id']);
+            }
         }
 
         return $orderData;

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Aug 22, 2024

Hi @sgeleon. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.7 Indicates original Magento version for the Issue report. label Aug 22, 2024
@engcom-Bravo engcom-Bravo self-assigned this Aug 22, 2024
Copy link

m2-assistant bot commented Aug 22, 2024

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@kulwinders433
Copy link

kulwinders433 commented Aug 23, 2024

I have also tried this now its working fine

@AndresInSpace
Copy link

AndresInSpace commented Aug 27, 2024

Are there any actual issues being caused with the hyphen in order string?

I believe alpha numerical with hyphen is widely accepted for order numbers and I have seen other systems use incremental for reorders as well.
IIRC in those systems incremental was used to decrease loading duplicate data as majority of data is copy of original order. Not sure how Magento handles it

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

Copy link

@engcom-Bravo
Copy link
Contributor

Hi @sgeleon,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Screenshot 2024-08-29 at 15 38 54

The order number is the same 8 digits as the previous order with “-1” added to the end.from frontend it is working fine.

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Component: Order grid Area: Order labels Aug 29, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-12854 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Aug 29, 2024

✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@atIOCrON
Copy link

Hi @AndresInSpace
Yes, the issue is from a logical standpoint from the admin/custommer side, the "-1" order number and "Link to previous order" have always been reserved for when orders are edited.

When an order is edited, the original order is cancelled and a new one is made to replace it. Therefore, it makes sense to have a "-1" appended to the order number and a "Link to the previous" order on the order view page because the new order replaces the old one.

When you use the reorder button you are telling Magento you want to place a brand new order that is similar to the previous one but that does not replace it. The reorder button is just a shortcut to order the same products for the same client instead of having to go through the new order process from scratch. It doesn't make any sense from the admin or customer side to use "-1" and "Link to the previous order" in this case.

Magento previously treated editing and reordering differently, now it is treating them the same. This is incorrect.

@natedawg92
Copy link

for anyone else experiencing this issue i opted to revert some of the changes that were made in #37298

diff --git a/Model/AdminOrder/Create.php b/Model/AdminOrder/Create.php
index 4b1868e..a791e2f 100644
--- a/Model/AdminOrder/Create.php
+++ b/Model/AdminOrder/Create.php
@@ -2044,10 +2044,8 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\
     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();
@@ -2074,16 +2072,12 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\
      */
     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();
         }
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Order Component: Order grid Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.7 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants