How to get tracking URL to email correctly in Magento 2.2?

by tgor   Last Updated May 23, 2018 19:09 PM

I'm trying to get carriers tracking url to shipping email. I followed this answer here and it is working correctly, but it uses the deprecated load method here:

public function getTrackingInfoByTrackId($trackId) { /** @var \Magento\Shipping\Model\Order\Track $track */ $track = $this->_trackFactory->create()->load($trackId); if ($track->getEntityId()) { $result = $track->getNumberDetail(); } else { $result = null; } return $result; }

Is there a simple way to rewrite this code to not use the load method? Is there some repository to get track details and tracking url? I'm new to Magento and trying to understand the concepts of Factories and Repositories and how to use them in this case.



Related Questions


M2 Tracking progress via API

Updated December 03, 2017 08:09 AM


importing and exporting tracking

Updated January 25, 2018 06:09 AM