Skip to content

Commit d05f8e9

Browse files
authored
Merge pull request #6844 from magento-performance/MCP-412
[Performance] Checkout enhancements
2 parents ccdb2a7 + 3c6b65e commit d05f8e9

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Checkout\Api\PaymentSavingRateLimiterInterface;
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Framework\Exception\CouldNotSaveException;
14+
use Magento\Quote\Api\CartRepositoryInterface;
1415

1516
/**
1617
* Payment information management service.
@@ -51,7 +52,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
5152
private $logger;
5253

5354
/**
54-
* @var \Magento\Quote\Api\CartRepositoryInterface
55+
* @var CartRepositoryInterface
5556
*/
5657
private $cartRepository;
5758

@@ -78,6 +79,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
7879
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
7980
* @param PaymentProcessingRateLimiterInterface|null $paymentRateLimiter
8081
* @param PaymentSavingRateLimiterInterface|null $saveRateLimiter
82+
* @param CartRepositoryInterface|null $cartRepository
8183
* @codeCoverageIgnore
8284
*/
8385
public function __construct(
@@ -87,7 +89,8 @@ public function __construct(
8789
\Magento\Checkout\Model\PaymentDetailsFactory $paymentDetailsFactory,
8890
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository,
8991
?PaymentProcessingRateLimiterInterface $paymentRateLimiter = null,
90-
?PaymentSavingRateLimiterInterface $saveRateLimiter = null
92+
?PaymentSavingRateLimiterInterface $saveRateLimiter = null,
93+
?CartRepositoryInterface $cartRepository = null
9194
) {
9295
$this->billingAddressManagement = $billingAddressManagement;
9396
$this->paymentMethodManagement = $paymentMethodManagement;
@@ -98,6 +101,8 @@ public function __construct(
98101
?? ObjectManager::getInstance()->get(PaymentProcessingRateLimiterInterface::class);
99102
$this->saveRateLimiter = $saveRateLimiter
100103
?? ObjectManager::getInstance()->get(PaymentSavingRateLimiterInterface::class);
104+
$this->cartRepository = $cartRepository
105+
?? ObjectManager::getInstance()->get(CartRepositoryInterface::class);
101106
}
102107

103108
/**
@@ -154,10 +159,8 @@ public function savePaymentInformation(
154159
}
155160

156161
if ($billingAddress) {
157-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
158-
$quoteRepository = $this->getCartRepository();
159162
/** @var \Magento\Quote\Model\Quote $quote */
160-
$quote = $quoteRepository->getActive($cartId);
163+
$quote = $this->cartRepository->getActive($cartId);
161164
$customerId = $quote->getBillingAddress()
162165
->getCustomerId();
163166
if (!$billingAddress->getCustomerId() && $customerId) {
@@ -204,19 +207,4 @@ private function getLogger()
204207
}
205208
return $this->logger;
206209
}
207-
208-
/**
209-
* Get Cart repository
210-
*
211-
* @return \Magento\Quote\Api\CartRepositoryInterface
212-
* @deprecated 100.2.0
213-
*/
214-
private function getCartRepository()
215-
{
216-
if (!$this->cartRepository) {
217-
$this->cartRepository = ObjectManager::getInstance()
218-
->get(\Magento\Quote\Api\CartRepositoryInterface::class);
219-
}
220-
return $this->cartRepository;
221-
}
222210
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
553553
$order->setCustomerFirstname($quote->getCustomerFirstname());
554554
$order->setCustomerMiddlename($quote->getCustomerMiddlename());
555555
$order->setCustomerLastname($quote->getCustomerLastname());
556+
557+
if ($quote->getOrigOrderId()) {
558+
$order->setEntityId($quote->getOrigOrderId());
559+
}
560+
561+
if ($quote->getReservedOrderId()) {
562+
$order->setIncrementId($quote->getReservedOrderId());
563+
}
564+
556565
$this->submitQuoteValidator->validateOrder($order);
557566

558567
$this->eventManager->dispatch(

app/code/Magento/Sales/Model/OrderRepository.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ private function setPaymentAdditionalInfo(OrderInterface $order): void
186186
if ($extensionAttributes === null) {
187187
$extensionAttributes = $this->orderExtensionFactory->create();
188188
}
189-
$paymentAdditionalInformation = $order->getPayment()->getAdditionalInformation();
189+
190+
$paymentAdditionalInformation = [];
191+
$payment = $order->getPayment();
192+
193+
if ($payment) {
194+
$paymentAdditionalInformation = $payment->getAdditionalInformation();
195+
}
190196

191197
$objects = [];
192198
foreach ($paymentAdditionalInformation as $key => $value) {

0 commit comments

Comments
 (0)