diff --git a/InventoryInStorePickup/Model/SearchRequest/Area/GetDistanceToSources.php b/InventoryInStorePickup/Model/SearchRequest/Area/GetDistanceToSources.php index 6f959f284bb..daa375a1187 100644 --- a/InventoryInStorePickup/Model/SearchRequest/Area/GetDistanceToSources.php +++ b/InventoryInStorePickup/Model/SearchRequest/Area/GetDistanceToSources.php @@ -14,6 +14,8 @@ use Magento\InventoryInStorePickupApi\Model\SearchRequest\Area\Pipeline; use Magento\InventorySourceSelectionApi\Api\Data\AddressInterface; use Magento\InventorySourceSelectionApi\Api\Data\AddressInterfaceFactory; +use Psr\Log\LoggerInterface; +use Magento\Framework\App\ObjectManager; /** * Provide associated list of Source codes and distance to them in KM. @@ -47,22 +49,30 @@ class GetDistanceToSources */ private $searchTermPipeline; + /** + * @var LoggerInterface + */ + private $logger; + /** * @param GetLatsLngsFromAddressInterface $getLatsLngsFromAddress * @param GetOrderedDistanceToSources $getOrderedDistanceToSources * @param AddressInterfaceFactory $addressInterfaceFactory * @param Pipeline $searchTermPipeline + * @param LoggerInterface $logger */ public function __construct( GetLatsLngsFromAddressInterface $getLatsLngsFromAddress, GetOrderedDistanceToSources $getOrderedDistanceToSources, AddressInterfaceFactory $addressInterfaceFactory, - Pipeline $searchTermPipeline + Pipeline $searchTermPipeline, + ?LoggerInterface $logger = null ) { $this->getLatsLngsFromAddress = $getLatsLngsFromAddress; $this->getOrderedDistanceToSources = $getOrderedDistanceToSources; $this->addressInterfaceFactory = $addressInterfaceFactory; $this->searchTermPipeline = $searchTermPipeline; + $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); } /** @@ -108,6 +118,7 @@ private function getDistanceToSources(AreaInterface $area): array try { $latsLngs = $this->getLatsLngsFromAddress->execute($sourceSelectionAddress); } catch (LocalizedException $exception) { + $this->logger->error($exception->getMessage()); return []; }