diff --git a/CHANGELOG.md b/CHANGELOG.md index 46c6edef..832a3448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,9 @@ - Bugfix when parcel terminal unconditionally changed to first selection while searching. - Upgrade added to avoid error when client upgrades modules and does not delete cache. - Bugfix when parcel tracking validation was called from prestashop core. Fall back to universal legacy function +- Logic to execute code further if error occurs on tracking email send. - Bugfix when parcel terminal form is always visible in order - Translatable string added when no option available, translations updated for all baltic languages for pickup select. + diff --git a/config/service.yml b/config/service.yml index 837b3baf..badb368e 100644 --- a/config/service.yml +++ b/config/service.yml @@ -260,6 +260,7 @@ services: arguments: - '@invertus.dpdbaltics.factory.parcel_tracking_url_factory' - '@dpdbaltics' + - '@invertus.dpdbaltics.logger.logger' invertus.dpdbaltics.service.carrier.prestashop_carrier_regeneration_handler: class: 'Invertus\dpdBaltics\Service\Carrier\PrestashopCarrierRegenerationHandler' diff --git a/src/Service/Email/Handler/ParcelTrackingEmailHandler.php b/src/Service/Email/Handler/ParcelTrackingEmailHandler.php index 3faaecff..aefd3acf 100644 --- a/src/Service/Email/Handler/ParcelTrackingEmailHandler.php +++ b/src/Service/Email/Handler/ParcelTrackingEmailHandler.php @@ -5,6 +5,7 @@ use Invertus\dpdBaltics\Exception\ParcelEmailException; use Invertus\dpdBaltics\Factory\ContextFactory; use Invertus\dpdBaltics\Factory\ParcelTrackingUrlFactory; +use Invertus\dpdBaltics\Logger\Logger; use Mail; use Module; use Validate; @@ -16,17 +17,25 @@ class ParcelTrackingEmailHandler */ private $trackingUrlFactory; + /** * @var Module */ private $module; + /** + * @var Logger + */ + private $logger; + public function __construct( ParcelTrackingUrlFactory $trackingUrlFactory, - Module $module + Module $module, + Logger $logger ) { $this->trackingUrlFactory = $trackingUrlFactory; $this->module = $module; + $this->logger = $logger; } /** @@ -36,17 +45,20 @@ public function __construct( public function handle($idOrder, $parcelNumbers) { if (!$idOrder) { - throw new ParcelEmailException('Could not retrieve order'); + $this->logger->log(Logger::ERROR, 'Could not retrieve order'); + return false; } $order = $this->getOrder($idOrder); if (empty($parcelNumbers)) { - throw new ParcelEmailException('Could not retrieve parcel number, failed to format email'); + $this->logger->log(Logger::ERROR, 'Could not retrieve parcel number, failed to format email ID Order: '. $idOrder); + return false; } + $cart = $this->getCartByOrderId($idOrder); if (!Validate::isLoadedObject($cart)) { - throw new ParcelEmailException('Could not retrieve order cart information'); + $this->logger->log(Logger::ERROR, 'Could not retrieve order cart information ID Order: '. $idOrder); } ContextFactory::getSmarty()->assign([