checkout-magento2-plugin icon indicating copy to clipboard operation
checkout-magento2-plugin copied to clipboard

Performance issue on checkout page.

Open kpitn opened this issue 3 years ago • 3 comments

Hi,

I'm using the last version module (4.1.1)

Instead of using order collection, repository is use with searchcriteria.

File : /vendor/checkoutcom/magento2/Model/Service/OrderHandlerService.php

        /** @var OrderInterface $order */
        $order = $this->orderRepository->getList($search)->setPageSize(1)->getLastItem();

Magento getlist load all customer orders before limiting the query with last item.

screen

items

kpitn avatar Sep 19 '22 15:09 kpitn

Patch to solve the problem (if you want to keep repository)

--- Model/Service/OrderHandlerService.php
+++ Model/Service/OrderHandlerService.php
@@ -289,10 +289,16 @@

         // Create the search instance
         $search = $this->searchBuilder->create();
+        /** @var SortOrder $sortOrder */
+        $sortOrder = \Magento\Framework\App\ObjectManager::getInstance()->create(\Magento\Framework\Api\SortOrderBuilder::class)
+            ->setField('created_at')
+            ->setDirection(\Magento\Framework\Api\SortOrder::SORT_ASC)
+            ->create();
+        $search->setPageSize(1)->setSortOrders([$sortOrder]);

         // Get the resulting order
         /** @var OrderInterface $order */
-        $order = $this->orderRepository->getList($search)->setPageSize(1)->getLastItem();
+        $order = $this->orderRepository->getList($search)->getLastItem();

         if ($order->getId()) {
             $this->logger->additional($this->getOrderDetails($order), 'order');

kpitn avatar Sep 19 '22 15:09 kpitn

Hello @kpitn ,

Thanks a lot for the feedback, very efficient as always! ;) This is taken into account and we will work on it in the near future.

We will keep you posted of our progress regarding this improvement.

Regards,

Dnd-Gimix avatar Sep 19 '22 15:09 Dnd-Gimix

I flagged the same in https://github.com/checkout/checkout-magento2-plugin/pull/503 but sadly, this was missed.

I'm undecided if I should continue to raise issues with this project.

Off the top of my head, there are

They've released versions that have broken filters (so crashed the checkout loading 2 million transactions to try and figure out the last payment method used), have put PHP 8.0 specific code in versions meant for 7.x, had invalid JS that broke checkouts.

Every time, it's an ordeal that ends up becoming a game of message passing between the internal support team and their Magento agency. I have 18 separate plugins, 8 class rewrites fixing or altering things on your extension. It's my preferred solution these days. It saves my time jumping through hoops to help a company that's valued at $40 billion.

JamesFX2 avatar Nov 09 '22 12:11 JamesFX2