|
14 | 14 | use Magento\InventoryInStorePickupApi\Model\SearchRequest\Area\Pipeline; |
15 | 15 | use Magento\InventorySourceSelectionApi\Api\Data\AddressInterface; |
16 | 16 | use Magento\InventorySourceSelectionApi\Api\Data\AddressInterfaceFactory; |
| 17 | +use Psr\Log\LoggerInterface; |
| 18 | +use Magento\Framework\App\ObjectManager; |
17 | 19 |
|
18 | 20 | /** |
19 | 21 | * Provide associated list of Source codes and distance to them in KM. |
@@ -47,22 +49,30 @@ class GetDistanceToSources |
47 | 49 | */ |
48 | 50 | private $searchTermPipeline; |
49 | 51 |
|
| 52 | + /** |
| 53 | + * @var LoggerInterface |
| 54 | + */ |
| 55 | + private $logger; |
| 56 | + |
50 | 57 | /** |
51 | 58 | * @param GetLatsLngsFromAddressInterface $getLatsLngsFromAddress |
52 | 59 | * @param GetOrderedDistanceToSources $getOrderedDistanceToSources |
53 | 60 | * @param AddressInterfaceFactory $addressInterfaceFactory |
54 | 61 | * @param Pipeline $searchTermPipeline |
| 62 | + * @param LoggerInterface $logger |
55 | 63 | */ |
56 | 64 | public function __construct( |
57 | 65 | GetLatsLngsFromAddressInterface $getLatsLngsFromAddress, |
58 | 66 | GetOrderedDistanceToSources $getOrderedDistanceToSources, |
59 | 67 | AddressInterfaceFactory $addressInterfaceFactory, |
60 | | - Pipeline $searchTermPipeline |
| 68 | + Pipeline $searchTermPipeline, |
| 69 | + ?LoggerInterface $logger = null |
61 | 70 | ) { |
62 | 71 | $this->getLatsLngsFromAddress = $getLatsLngsFromAddress; |
63 | 72 | $this->getOrderedDistanceToSources = $getOrderedDistanceToSources; |
64 | 73 | $this->addressInterfaceFactory = $addressInterfaceFactory; |
65 | 74 | $this->searchTermPipeline = $searchTermPipeline; |
| 75 | + $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); |
66 | 76 | } |
67 | 77 |
|
68 | 78 | /** |
@@ -108,6 +118,7 @@ private function getDistanceToSources(AreaInterface $area): array |
108 | 118 | try { |
109 | 119 | $latsLngs = $this->getLatsLngsFromAddress->execute($sourceSelectionAddress); |
110 | 120 | } catch (LocalizedException $exception) { |
| 121 | + $this->logger->error($exception->getMessage()); |
111 | 122 | return []; |
112 | 123 | } |
113 | 124 |
|
|
0 commit comments