Skip to content

Commit 0168b1f

Browse files
nmalevanecLars Roettig
authored and
Lars Roettig
committed
Fix static tests.
1 parent 9141077 commit 0168b1f

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

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

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -529,28 +529,7 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
529529
);
530530
$this->quoteRepository->save($quote);
531531
} catch (\Exception $e) {
532-
try {
533-
if (!empty($this->addressesToSync)) {
534-
foreach ($this->addressesToSync as $addressId) {
535-
$this->addressRepository->deleteById($addressId);
536-
}
537-
}
538-
$this->eventManager->dispatch(
539-
'sales_model_service_quote_submit_failure',
540-
[
541-
'order' => $order,
542-
'quote' => $quote,
543-
'exception' => $e,
544-
]
545-
);
546-
} catch (\Exception $consecutiveException) {
547-
$message = sprintf(
548-
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
549-
$consecutiveException->getMessage()
550-
);
551-
552-
throw new \Exception($message, 0, $e);
553-
}
532+
$this->rollbackAddresses($quote, $order, $e);
554533
throw $e;
555534
}
556535
return $order;
@@ -617,4 +596,41 @@ protected function _prepareCustomerQuote($quote)
617596
$shipping->setIsDefaultBilling(true);
618597
}
619598
}
599+
600+
/**
601+
* Remove related to order and quote addresses and submit exception to further processing.
602+
*
603+
* @param Quote $quote
604+
* @param \Magento\Sales\Api\Data\OrderInterface $order
605+
* @param \Exception $e
606+
* @throws \Exception
607+
*/
608+
private function rollbackAddresses(
609+
QuoteEntity $quote,
610+
\Magento\Sales\Api\Data\OrderInterface $order,
611+
\Exception $e
612+
): void {
613+
try {
614+
if (!empty($this->addressesToSync)) {
615+
foreach ($this->addressesToSync as $addressId) {
616+
$this->addressRepository->deleteById($addressId);
617+
}
618+
}
619+
$this->eventManager->dispatch(
620+
'sales_model_service_quote_submit_failure',
621+
[
622+
'order' => $order,
623+
'quote' => $quote,
624+
'exception' => $e,
625+
]
626+
);
627+
} catch (\Exception $consecutiveException) {
628+
$message = sprintf(
629+
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
630+
$consecutiveException->getMessage()
631+
);
632+
633+
throw new \Exception($message, 0, $e);
634+
}
635+
}
620636
}

0 commit comments

Comments
 (0)