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 new file mode 100644 index 000000000000..eb9c31c32a08 --- /dev/null +++ b/vendor/magento/module-checkout-address-search/Plugin/Customer/Model/Address/CustomerAddressDataProvider.php @@ -0,0 +1,61 @@ +config = $config; + } + + /** + * If address search is enabled we should limit the number of addresses required + * + * @param AddressDataProvider $subject + * @param CustomerInterface $customer + * @param int|null $addressLimit + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeGetAddressDataByCustomer( + AddressDataProvider $subject, + CustomerInterface $customer, + ?int $addressLimit = null + ): array { + if ($this->config->isEnabledAddressSearch()) { + $addressLimit = $this->config->getSearchLimit(); + } + + return [$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 0632a7808a33..bb5a52526556 100644 --- a/vendor/magento/module-checkout-address-search/etc/frontend/di.xml +++ b/vendor/magento/module-checkout-address-search/etc/frontend/di.xml @@ -14,4 +14,7 @@ + + +