From 31511ce752b9e80932f15939f886553bd8b3ab0a Mon Sep 17 00:00:00 2001 From: Hidro Le Date: Thu, 7 Apr 2022 12:22:03 +0700 Subject: [PATCH 1/2] optimize-contructor: - Remove $session->getQuote from constructor - Load the quote when it is needed. --- Block/Onepage/AffirmButton.php | 22 +++++++++++++-- Controller/Payment/Confirm.php | 30 ++++++++++++++++---- Helper/FinancingProgram.php | 26 ++++++++++++++--- Helper/Payment.php | 34 ++++++++++++++++------ Model/AffirmCheckoutManager.php | 41 +++++++++++++++++---------- Model/Checkout.php | 50 ++++++++++++++++++++------------- Model/GiftWrapManager.php | 28 ++++++++++++------ Model/InlineCheckout.php | 36 ++++++++++++++++++------ 8 files changed, 196 insertions(+), 71 deletions(-) diff --git a/Block/Onepage/AffirmButton.php b/Block/Onepage/AffirmButton.php index f7441ff2..98e7c8f7 100644 --- a/Block/Onepage/AffirmButton.php +++ b/Block/Onepage/AffirmButton.php @@ -48,7 +48,12 @@ class AffirmButton extends Template * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; + + /** + * @var \Magento\Checkout\Model\Session + */ + protected $session; /** * Button template @@ -72,10 +77,23 @@ public function __construct( array $data = [] ) { $this->helper = $helper; - $this->quote = $session->getQuote(); + $this->session = $session; parent::__construct($context, $data); } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + /** * Get button image from system configs * diff --git a/Controller/Payment/Confirm.php b/Controller/Payment/Confirm.php index d470213d..70044e28 100644 --- a/Controller/Payment/Confirm.php +++ b/Controller/Payment/Confirm.php @@ -83,6 +83,11 @@ class Confirm extends Action implements CsrfAwareActionInterface */ protected $quote; + /** + * @var \Magento\Checkout\Model\Session + */ + protected $session; + /** * Inject objects to the Confirm action * @@ -100,10 +105,23 @@ public function __construct( $this->checkout = $checkout; $this->checkoutSession = $checkoutSession; $this->quoteManagement = $quoteManager; - $this->quote = $checkoutSession->getQuote(); + $this->session = $checkoutSession; parent::__construct($context); } - + + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + /** * @inheritDoc */ @@ -112,14 +130,14 @@ public function createCsrfValidationException( ): ?InvalidRequestException { return null; } - + /** * @inheritDoc */ public function validateForCsrf(RequestInterface $request): ?bool { return true; - } + } /** * Dispatch request @@ -137,7 +155,7 @@ public function execute() $this->checkoutSession->clearHelperData(); // "last successful quote" - $quoteId = $this->quote->getId(); + $quoteId = $this->getQuote()->getId(); $this->checkoutSession->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId); // an order may be created @@ -149,7 +167,7 @@ public function execute() } $this->_eventManager->dispatch( 'affirm_place_order_success', - ['order' => $order, 'quote' => $this->quote ] + ['order' => $order, 'quote' => $this->getQuote() ] ); $this->_redirect('checkout/onepage/success'); return; diff --git a/Helper/FinancingProgram.php b/Helper/FinancingProgram.php index 26284d05..acaf63f9 100644 --- a/Helper/FinancingProgram.php +++ b/Helper/FinancingProgram.php @@ -44,7 +44,12 @@ class FinancingProgram * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; + + /** + * @var \Magento\Checkout\Model\Session + */ + protected $session; /** * Customer session @@ -120,7 +125,7 @@ public function __construct( CategoryCollectionFactory $categoryCollectionFactory ) { $this->customerSession = $customerSession; - $this->quote = $session->getQuote(); + $this->session = $session; $this->scopeConfig = $scopeConfig; $this->affirmPaymentConfig = $configAffirm; $this->_localeDate = $localeDate; @@ -130,6 +135,19 @@ public function __construct( $this->_init(); } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + /** * Initialization * @@ -257,7 +275,7 @@ public function getCustomerFinancingProgram() protected function getQuoteProductCollection() { if (null === $this->products) { - $visibleQuoteItems = $this->quote->getAllVisibleItems(); + $visibleQuoteItems = $this->getQuote()->getAllVisibleItems(); $productIds = []; foreach ($visibleQuoteItems as $visibleQuoteItem) { $productIds[] = $visibleQuoteItem->getProductId(); @@ -496,7 +514,7 @@ protected function getFinancingProgramFromCategoriesALS($productCollection) */ protected function getQuoteBaseGrandTotal() { - return $this->quote->getBaseGrandTotal(); + return $this->getQuote()->getBaseGrandTotal(); } /** diff --git a/Helper/Payment.php b/Helper/Payment.php index bf920dfa..6fe5877a 100644 --- a/Helper/Payment.php +++ b/Helper/Payment.php @@ -54,7 +54,12 @@ class Payment * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; + + /** + * @var \Magento\Checkout\Model\Session + */ + protected $session; /** * Method specification factory @@ -149,7 +154,7 @@ public function __construct( ) { $this->methodSpecificationFactory = $methodSpecificationFactory; $this->payment = $payment; - $this->quote = $session->getQuote(); + $this->session = $session; $this->customerSession = $customerSession; $this->storeManager = $storeManagerInterface; $this->design = $design; @@ -160,6 +165,19 @@ public function __construct( $this->stockRegistry = $stockRegistry; } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + /** * Get placeholder image * @@ -191,7 +209,7 @@ public function isAffirmAvailable() AbstractMethod::CHECK_USE_FOR_CURRENCY, AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, ]; - if ($this->quote->getIsVirtual() && !$this->quote->getCustomerId()) { + if ($this->getQuote()->getIsVirtual() && !$this->getQuote()->getCustomerId()) { $checkData[] = AbstractMethod::CHECK_USE_FOR_COUNTRY; } @@ -199,11 +217,11 @@ public function isAffirmAvailable() ->create($checkData) ->isApplicable( $this->payment, - $this->quote + $this->getQuote() ); if ($check && $this->validateVirtual()) { - return $this->payment->isAvailable($this->quote); + return $this->payment->isAvailable($this->getQuote()); } return false; } @@ -310,12 +328,12 @@ public function getConfigurableProductBackordersOptions(Product $product = null) */ public function validateVirtual() { - if ($this->quote->getIsVirtual() && !$this->quote->getCustomerIsGuest()) { + if ($this->getQuote()->getIsVirtual() && !$this->getQuote()->getCustomerIsGuest()) { $countryId = self::VALIDATE_COUNTRY; // get customer addresses list - $addresses = $this->quote->getCustomer()->getAddresses(); + $addresses = $this->getQuote()->getCustomer()->getAddresses(); // get default shipping address for the customer - $defaultShipping = $this->quote->getCustomer()->getDefaultShipping(); + $defaultShipping = $this->getQuote()->getCustomer()->getDefaultShipping(); /** @var $address \Magento\Customer\Api\Data\AddressInterface */ if ($defaultShipping) { foreach ($addresses as $address) { diff --git a/Model/AffirmCheckoutManager.php b/Model/AffirmCheckoutManager.php index dc1f819d..c53e438b 100644 --- a/Model/AffirmCheckoutManager.php +++ b/Model/AffirmCheckoutManager.php @@ -62,7 +62,7 @@ class AffirmCheckoutManager implements AffirmCheckoutManagerInterface * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; /** * Injected repository @@ -136,7 +136,6 @@ public function __construct( Logger $logger ) { $this->checkoutSession = $checkoutSession; - $this->quote = $this->checkoutSession->getQuote(); $this->quoteRepository = $quoteRepository; $this->productMetadata = $productMetadata; $this->moduleResource = $moduleResource; @@ -146,6 +145,19 @@ public function __construct( $this->logger = $logger; } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->checkoutSession->getQuote(); + } + return $this->quote; + } + /** * Init checkout and get retrieve increment id * form affirm checkout @@ -156,11 +168,11 @@ public function __construct( public function initCheckout() { // collection totals before submit - $this->quote->collectTotals(); - $this->quote->reserveOrderId(); - $orderIncrementId = $this->quote->getReservedOrderId(); - $discountAmount = $this->quote->getBaseSubtotal() - $this->quote->getBaseSubtotalWithDiscount(); - $shippingAddress = $this->quote->getShippingAddress(); + $this->getQuote()->collectTotals(); + $this->getQuote()->reserveOrderId(); + $orderIncrementId = $this->getQuote()->getReservedOrderId(); + $discountAmount = $this->getQuote()->getBaseSubtotal() - $this->getQuote()->getBaseSubtotalWithDiscount(); + $shippingAddress = $this->getQuote()->getShippingAddress(); $response = []; if ($discountAmount > 0.001) { @@ -173,11 +185,10 @@ public function initCheckout() } try { - $country = $this - ->quote + $country = $this->getQuote() ->getBillingAddress() ->getCountry(); - $result = $this->quote + $result = $this->getQuote() ->getPayment() ->getMethodInstance() ->canUseForCountry($country); @@ -190,7 +201,7 @@ public function initCheckout() return $e->getMessage(); } if ($orderIncrementId) { - $this->quoteRepository->save($this->quote); + $this->quoteRepository->save($this->getQuote()); $response['order_increment_id'] = $orderIncrementId; } if ($this->productMetadata->getEdition() == 'Enterprise') { @@ -199,7 +210,7 @@ public function initCheckout() if ($wrapped) { $response['wrapped_items'] = $wrapped; } - $giftCards = $this->quote->getGiftCards(); + $giftCards = $this->getQuote()->getGiftCards(); if ($giftCards) { $giftCards = json_decode($giftCards); foreach ($giftCards as $giftCard) { @@ -213,7 +224,7 @@ public function initCheckout() $itemTypes = array(); - $items = $this->quote->getAllVisibleItems(); + $items = $this->getQuote()->getAllVisibleItems(); foreach ($items as $item) { $itemTypes[] = $item->getProductType(); } @@ -248,7 +259,7 @@ public function initCheckout() } private function getShippingAddress(){ - $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress = $this->getQuote()->getShippingAddress(); $shippingObject = array( 'name' => array( 'full_name' => $shippingAddress->getName(), @@ -267,7 +278,7 @@ private function getShippingAddress(){ } private function getBillingAddress(){ - $billingAddress = $this->quote->getBillingAddress(); + $billingAddress = $this->getQuote()->getBillingAddress(); $billingObject = array( 'name' => array( 'full_name' => $billingAddress->getName(), diff --git a/Model/Checkout.php b/Model/Checkout.php index 87b70e12..3454a5fc 100644 --- a/Model/Checkout.php +++ b/Model/Checkout.php @@ -59,7 +59,7 @@ class Checkout * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; /** * Customer session object @@ -119,7 +119,6 @@ public function __construct( ) { $this->checkoutSession = $checkoutSession; $this->quoteManagement = $cartManagement; - $this->quote = $this->checkoutSession->getQuote(); $this->customerSession = $customerSession; $this->checkoutData = $checkoutData; $this->orderSender = $orderSender; @@ -135,12 +134,25 @@ public function __construct( && $params['session'] instanceof \Magento\Customer\Model\Session ? $params['session'] : $customerSession; } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->checkoutSession->getQuote(); + } + return $this->quote; + } + /** * Place order based on prepared quote */ public function place($token) { - if (!$this->quote->getGrandTotal()) { + if (!$this->getQuote()->getGrandTotal()) { throw new \Magento\Framework\Exception\LocalizedException( __( 'Affirm can\'t process orders with a zero balance due. ' @@ -159,9 +171,9 @@ public function place($token) if ($this->getCheckoutMethod() == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) { $this->prepareGuestQuote(); } - $this->quote->collectTotals(); + $this->getQuote()->collectTotals(); $this->ignoreAddressValidation(); - $this->order = $this->quoteManagement->submit($this->quote); + $this->order = $this->quoteManagement->submit($this->getQuote()); switch ($this->order->getState()) { // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money @@ -200,14 +212,14 @@ protected function getCheckoutMethod() if ($this->getCustomerSession()->isLoggedIn()) { return \Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER; } - if (!$this->quote->getCheckoutMethod()) { - if ($this->checkoutData->isAllowedGuestCheckout($this->quote)) { - $this->quote->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST); + if (!$this->getQuote()->getCheckoutMethod()) { + if ($this->checkoutData->isAllowedGuestCheckout($this->getQuote())) { + $this->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST); } else { - $this->quote->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); + $this->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); } } - return $this->quote->getCheckoutMethod(); + return $this->getQuote()->getCheckoutMethod(); } /** @@ -217,7 +229,7 @@ protected function getCheckoutMethod() */ protected function prepareGuestQuote() { - $quote = $this->quote; + $quote = $this->getQuote(); $quote->setCustomerId(null) ->setCustomerEmail($quote->getBillingAddress()->getEmail()) ->setCustomerIsGuest(true) @@ -232,13 +244,13 @@ protected function prepareGuestQuote() */ protected function ignoreAddressValidation() { - $this->quote->getBillingAddress()->setShouldIgnoreValidation(true); - if (!$this->quote->getIsVirtual()) { - $this->quote->getShippingAddress()->setShouldIgnoreValidation(true); + $this->getQuote()->getBillingAddress()->setShouldIgnoreValidation(true); + if (!$this->getQuote()->getIsVirtual()) { + $this->getQuote()->getShippingAddress()->setShouldIgnoreValidation(true); if (!$this->config->getValue('requireBillingAddress') - && !$this->quote->getBillingAddress()->getEmail() + && !$this->getQuote()->getBillingAddress()->getEmail() ) { - $this->quote->getBillingAddress()->setSameAsBilling(1); + $this->getQuote()->getBillingAddress()->setSameAsBilling(1); } } } @@ -251,7 +263,7 @@ protected function ignoreAddressValidation() */ public function setCustomerData(CustomerDataObject $customerData) { - $this->quote->assignCustomer($customerData); + $this->getQuote()->assignCustomer($customerData); $this->customerId = $customerData->getId(); return $this; } @@ -275,7 +287,7 @@ public function getOrder() protected function initToken($token) { if ($token) { - $payment = $this->quote->getPayment(); + $payment = $this->getQuote()->getPayment(); $payment->setAdditionalInformation('checkout_token', $token); $payment->save(); } @@ -294,7 +306,7 @@ public function setCustomerWithAddressChange( $billingAddress = null, $shippingAddress = null ) { - $this->quote->assignCustomerWithAddressChange($customerData, $billingAddress, $shippingAddress); + $this->getQuote()->assignCustomerWithAddressChange($customerData, $billingAddress, $shippingAddress); $this->customerId = $customerData->getId(); return $this; } diff --git a/Model/GiftWrapManager.php b/Model/GiftWrapManager.php index 897d3f3a..1b03c62c 100644 --- a/Model/GiftWrapManager.php +++ b/Model/GiftWrapManager.php @@ -43,7 +43,7 @@ class GiftWrapManager implements GiftWrapManagerInterface * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; /** * Wrapping repository class @@ -86,11 +86,23 @@ public function __construct( PaymentHelper $paymentHelper ) { $this->session = $checkoutSession; - $this->quote = $checkoutSession->getQuote(); $this->wrappingRepository = $objectManager->create('Magento\GiftWrapping\Api\WrappingRepositoryInterface'); $this->imageHelper = $paymentHelper; } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + /** * Get current store id * @@ -98,7 +110,7 @@ public function __construct( */ public function getStoreId() { - return $this->quote->getStoreId(); + return $this->getQuote()->getStoreId(); } /** @@ -108,14 +120,14 @@ public function getStoreId() */ public function getPrintedCardItem() { - $isApplicable = $this->quote->getGwAddCard(); + $isApplicable = $this->getQuote()->getGwAddCard(); if ($isApplicable) { - $printedCardPrice = $this->quote->getGwCardBasePrice(); + $printedCardPrice = $this->getQuote()->getGwCardBasePrice(); if ($printedCardPrice) { return [ "display_name" => "Printed Card", "sku" => "printed-card", - "unit_price" => Util::formatToCents($this->quote->getGwCardBasePrice()), + "unit_price" => Util::formatToCents($this->getQuote()->getGwCardBasePrice()), "qty" => 1, "item_image_url" => $this->imageHelper->getPlaceholderImage(), "item_url" => $this->imageHelper->getPlaceholderImage() @@ -131,7 +143,7 @@ public function getPrintedCardItem() */ public function getWrapItems() { - $wrappedIdForOrder = $this->quote->getGwId(); + $wrappedIdForOrder = $this->getQuote()->getGwId(); $data = []; if ($wrappedIdForOrder) { /** @var \Magento\GiftWrapping\Api\Data\WrappingInterface $wrapItem */ @@ -177,7 +189,7 @@ protected function processItemData($wrapItem) */ protected function prepareWrapForItems($data) { - $quoteItems = $this->quote->getAllItems(); + $quoteItems = $this->getQuote()->getAllItems(); /** @var \Magento\Quote\Model\Quote\Item $item */ foreach ($quoteItems as $item) { diff --git a/Model/InlineCheckout.php b/Model/InlineCheckout.php index 1fe16ac7..a13af061 100644 --- a/Model/InlineCheckout.php +++ b/Model/InlineCheckout.php @@ -4,6 +4,7 @@ use Astound\Affirm\Gateway\Helper\Util; use Magento\Checkout\Model\Session; use Astound\Affirm\Api\InlineCheckoutInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Module\ResourceInterface; use Magento\Framework\UrlInterface; @@ -21,27 +22,32 @@ class InlineCheckout implements InlineCheckoutInterface * @var Session */ private $session; + /** * @var \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote */ - private $quote; + private $quote = null; + /** * @var UrlInterface */ private $urlBuilder; + /** * @var ResourceInterface */ private $moduleResource; + /** * @var ProductMetadataInterface */ private $productMetadata; /** - * @var Astound\Affirm\Gateway\Helper\Util + * @var \Astound\Affirm\Gateway\Helper\Util */ private $util; + /** * @var QuoteValidator */ @@ -56,7 +62,6 @@ public function __construct( QuoteValidator $quoteValidator ){ $this->session = $checkoutSession; - $this->quote = $checkoutSession->getQuote(); $this->urlBuilder = $urlInterface; $this->moduleResource = $moduleResource; $this->productMetadata = $productMetadata; @@ -64,8 +69,21 @@ public function __construct( $this->quoteValidator = $quoteValidator; } + /** + * Return current quote from checkout session. + * @return \Magento\Quote\Api\Data\CartInterface|\Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getQuote(){ + if(null == $this->quote){ + $this->quote = $this->session->getQuote(); + } + return $this->quote; + } + public function initInline(){ - $quote = $this->quote; + $quote = $this->getQuote(); $quote->collectTotals(); if(!$quote->getReservedOrderId()) { @@ -123,7 +141,7 @@ public function initInline(){ $checkoutObject['billing'] = $billingAddress; } - $discountAmount = $this->quote->getBaseSubtotal() - $this->quote->getBaseSubtotalWithDiscount(); + $discountAmount = $this->getQuote()->getBaseSubtotal() - $this->getQuote()->getBaseSubtotalWithDiscount(); if ($discountAmount > 0.001) { $checkoutObject['discounts']['discount'] = [ 'discount_amount' => Util::formatToCents($discountAmount) @@ -131,18 +149,18 @@ public function initInline(){ } if ($this->productMetadata->getEdition() == 'Enterprise') { - $giftWrapperItemsManager = $this->objectManager->create('Astound\Affirm\Api\GiftWrapManagerInterface'); + $giftWrapperItemsManager = ObjectManager::getInstance()->create('Astound\Affirm\Api\GiftWrapManagerInterface'); $wrapped = $giftWrapperItemsManager->getWrapItems(); if ($wrapped) { $checkoutObject['wrapped_items'] = $wrapped; } - $giftCards = $this->quote->getGiftCards(); + $giftCards = $this->getQuote()->getGiftCards(); if ($giftCards) { $giftCards = json_decode($giftCards); foreach ($giftCards as $giftCard) { - $giftCardDiscountDescription = sprintf(__('Gift Card (%s)'), $giftCard[self::ID]); + $giftCardDiscountDescription = sprintf(__('Gift Card (%s)'), $giftCard[AffirmCheckoutManager::ID]); $checkoutObject['discounts'][$giftCardDiscountDescription] = [ - 'discount_amount' => Util::formatToCents($giftCard[self::AMOUNT]) + 'discount_amount' => Util::formatToCents($giftCard[AffirmCheckoutManager::AMOUNT]) ]; } } From 6fee9ed0b7ff117eea51d64c926e40d996369812 Mon Sep 17 00:00:00 2001 From: Hidro Le Date: Thu, 7 Apr 2022 12:33:43 +0700 Subject: [PATCH 2/2] optimize-constructor: adding default value for --- Controller/Payment/Confirm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Payment/Confirm.php b/Controller/Payment/Confirm.php index 70044e28..f473fa5d 100644 --- a/Controller/Payment/Confirm.php +++ b/Controller/Payment/Confirm.php @@ -81,7 +81,7 @@ class Confirm extends Action implements CsrfAwareActionInterface * * @var \Magento\Quote\Model\Quote */ - protected $quote; + protected $quote = null; /** * @var \Magento\Checkout\Model\Session