Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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 [];
}

Expand Down