Skip to content

Commit

Permalink
Merge pull request #146 from vippsas/publication-2.4.35
Browse files Browse the repository at this point in the history
VIPPS-417: Improve performance of GetShippingDetails service
  • Loading branch information
voleye authored Oct 31, 2022
2 parents d5fa264 + cf783b6 commit 35d6aef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
29 changes: 15 additions & 14 deletions Model/QuoteLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,38 @@
*/
namespace Vipps\Payment\Model;

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteRepository;
use Vipps\Checkout\Api\QuoteRepositoryInterface as VippsQuoteRepositoryInterface;

/**
* Class QuoteLocator
* @package Vipps\Payment\Model
*/
class QuoteLocator
{
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* @var QuoteRepository
*/
private $quoteRepository;
/**
* @var VippsQuoteRepositoryInterface
*/
private VippsQuoteRepositoryInterface $vippsQuoteRepository;

/**
* QuoteLocator constructor.
*
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param QuoteRepository $quoteRepository
* @param VippsQuoteRepositoryInterface $vippsQuoteRepository
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
QuoteRepository $quoteRepository
QuoteRepository $quoteRepository,
VippsQuoteRepositoryInterface $vippsQuoteRepository
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->quoteRepository = $quoteRepository;
$this->vippsQuoteRepository = $vippsQuoteRepository;
}

/**
Expand All @@ -59,10 +58,12 @@ public function __construct(
*/
public function get($incrementId): ?CartInterface
{
$searchCriteria = $this->searchCriteriaBuilder->addFilter('reserved_order_id', $incrementId, 'eq')
->create();
$quoteList = $this->quoteRepository->getList($searchCriteria)->getItems();
$quote = current($quoteList);
try {
$vippsQuote = $this->vippsQuoteRepository->loadByOrderId($incrementId);
$quote = $this->quoteRepository->get($vippsQuote->getQuoteId());
} catch (\Exception $e) {
$quote = null;
}

return $quote ?: null;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "magento2-module",
"description": "Vipps Payment Method",
"license": "proprietary",
"version": "2.4.34",
"version": "2.4.35",
"require": {
"magento/framework": "103.0.*",
"magento/module-sales": "103.0.*",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
~ IN THE SOFTWARE.
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vipps_Payment" setup_version="2.4.34">
<module name="Vipps_Payment" setup_version="2.4.35">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 35d6aef

Please sign in to comment.