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

Duplicate orders being created #4

Open
zakisaad opened this issue Nov 2, 2020 · 2 comments
Open

Duplicate orders being created #4

zakisaad opened this issue Nov 2, 2020 · 2 comments

Comments

@zakisaad
Copy link

zakisaad commented Nov 2, 2020

I have installed and configured this plugin for a client of mine; the plugin is working as expected except for a couple of minor issues (and a fairly major one as I will describe below).

Seemingly randomly, Mirakl orders will be duplicated on the Magento end. Most orders come through into Magento as a 1:1 map, but every now and then a single Mirakl order will create 2 or 3 Magento orders.

In these cases (1:2 or 1:3 duplication ratio), the orders as brought in with the same cron job, that is, seconds apart (within very brief moments of each other).

Is this something that has been experienced while developing the plugin, is there something we can knock out simply before going down the direct debug path? The modules look well developed and straightforward, I can't fault the implementation (will need to debug the cron process directly with some test orders).

Auto-accept AND auto-create order settings are both on.

I have made a single, small patch to prefix order numbers. Apart from this, the codebase is clean (v1.2.8):

diff --git a/orig b/orig
index ab4ef8f..2e22177 100644
--- a/Sales/Model/Create/Order.php
+++ b/Sales/Model/Create/Order.php
@@ -122,6 +122,13 @@
             ->setIsSuperMode(true)
             ->setFromMiraklOrder(true);
 
+        // - prefix
+        $quote->reserveOrderId();
+        $quote->setReservedOrderId(
+            'B' . (string) $quote->getReservedOrderId()
+        );
+        // + prefix
+
         /** @var QuoteResource $quoteResource */
         $quoteResource = $this->objectManager->get(QuoteResource::class);
         $quoteResource->save($quote);
@jreinke
Copy link
Collaborator

jreinke commented Nov 5, 2020

Hello,

Thanks for your feedback.

To be honest, we already had such a feedback about duplicate orders but we were never able to reproduce the bug.
The code is designed to avoid this bug thanks to the mirakl_order_id field but it seems that something wrong is happening in some random cases.

I will be glad to help debugging this if you are able to reproduce the bug.

@zakisaad
Copy link
Author

zakisaad commented Dec 7, 2021

Hi @jreinke,

Thank you for this context (over a year ago)!

By any chance, does the latest version of the module still exhibit this issue? We are still on a version from over a year ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants