Skip to content

Commit 373dd92

Browse files
committed
ACP2E-2055: Duplicate orders with same Quote Id at same time with few time difference
1 parent fa67de7 commit 373dd92

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,7 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
544544
$order = $this->orderFactory->create();
545545
$this->submitQuoteValidator->validateQuote($quote);
546546
if (!$quote->getCustomerIsGuest()) {
547-
if ($quote->getCustomerId()) {
548-
$this->_prepareCustomerQuote($quote);
549-
$this->customerManagement->validateAddresses($quote);
550-
}
551-
$this->customerManagement->populateCustomerInfo($quote);
547+
$this->prepareCustomerQuote($quote);
552548
}
553549
$addresses = [];
554550
$quote->reserveOrderId();
@@ -780,4 +776,22 @@ public function _resetState(): void
780776
{
781777
$this->addressesToSync = [];
782778
}
779+
780+
/**
781+
* Prepare customer quote.
782+
*
783+
* @param Quote $quote
784+
* @return void
785+
* @throws LocalizedException
786+
* @throws NoSuchEntityException
787+
* @throws ValidatorException
788+
*/
789+
private function prepareCustomerQuote(Quote $quote): void
790+
{
791+
if ($quote->getCustomerId()) {
792+
$this->_prepareCustomerQuote($quote);
793+
$this->customerManagement->validateAddresses($quote);
794+
}
795+
$this->customerManagement->populateCustomerInfo($quote);
796+
}
783797
}

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ public function testSubmit(): void
837837
['order' => $order, 'quote' => $quote]
838838
]
839839
);
840-
$this->lockManagerMock->method('isLocked')->willReturn(false);
840+
$this->lockManagerMock->method('lock')->willReturn(true);
841841
$this->quoteRepositoryMock->expects($this->once())->method('save')->with($quote);
842842
$this->assertEquals($order, $this->model->submit($quote, $orderData));
843843
}
@@ -1311,6 +1311,7 @@ public function testSubmitForCustomer(): void
13111311
false
13121312
);
13131313

1314+
$this->lockManagerMock->method('lock')->willReturn(true);
13141315
$this->submitQuoteValidator->method('validateQuote')
13151316
->with($quote);
13161317
$this->quoteAddressToOrder->expects($this->once())

0 commit comments

Comments
 (0)