diff --git a/vendor/magento/module-checkout-address-search/Block/Checkout/CustomerAddressProcessor.php b/vendor/magento/module-checkout-address-search/Block/Checkout/CustomerAddressProcessor.php index 450a0a55b22d..fd680c75af30 100644 --- a/vendor/magento/module-checkout-address-search/Block/Checkout/CustomerAddressProcessor.php +++ b/vendor/magento/module-checkout-address-search/Block/Checkout/CustomerAddressProcessor.php @@ -1,7 +1,21 @@ customerRepository->getById($quote->getCustomerId()); - $customerAddressesData = $this->getCustomerAddressData($customer, $quote); + $customerAddressesData = $this->getCustomerAddressesData($customer, $quote); $addresses = []; foreach ($customerAddressesData as $address) { @@ -96,7 +110,7 @@ public function getFormattedOptions(\Magento\Quote\Model\Quote $quote): array * @return array * @throws \Magento\Framework\Exception\LocalizedException */ - private function getCustomerAddressData( + public function getCustomerAddressesData( \Magento\Customer\Api\Data\CustomerInterface $customer, \Magento\Quote\Model\Quote $quote ): array { diff --git a/vendor/magento/module-checkout-address-search/Plugin/Customer/Model/Address/CustomerAddressDataProvider.php b/vendor/magento/module-checkout-address-search/Plugin/Customer/Model/Address/CustomerAddressDataProvider.php index eb9c31c32a08..437854f3ba84 100644 --- a/vendor/magento/module-checkout-address-search/Plugin/Customer/Model/Address/CustomerAddressDataProvider.php +++ b/vendor/magento/module-checkout-address-search/Plugin/Customer/Model/Address/CustomerAddressDataProvider.php @@ -1,10 +1,12 @@ config = $config; + public function __construct( + private readonly CustomerAddressSearchConfig $config, + private readonly CustomerAddressProcessor $customerAddressProcessor, + private readonly CheckoutSession $checkoutSession + ) { } /** * If address search is enabled we should limit the number of addresses required * * @param AddressDataProvider $subject + * @param callable $proceed * @param CustomerInterface $customer * @param int|null $addressLimit * @return array + * @throws LocalizedException + * @throws NoSuchEntityException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeGetAddressDataByCustomer( + public function aroundGetAddressDataByCustomer( AddressDataProvider $subject, + callable $proceed, CustomerInterface $customer, ?int $addressLimit = null ): array { if ($this->config->isEnabledAddressSearch()) { - $addressLimit = $this->config->getSearchLimit(); + return $this->customerAddressProcessor->getCustomerAddressesData( + $customer, + $this->checkoutSession->getQuote() + ); } - return [$customer, $addressLimit]; + return $proceed($customer, $addressLimit); } } diff --git a/vendor/magento/module-checkout-address-search/etc/frontend/di.xml b/vendor/magento/module-checkout-address-search/etc/frontend/di.xml index bb5a52526556..efe803dd5f0d 100644 --- a/vendor/magento/module-checkout-address-search/etc/frontend/di.xml +++ b/vendor/magento/module-checkout-address-search/etc/frontend/di.xml @@ -1,8 +1,22 @@ @@ -17,4 +31,9 @@ + + + Magento\Checkout\Model\Session\Proxy + +