User below code sample to get the tacking information by order_id
Table name : sales_shipment_track
use Magento\Sales\Model\Order\Shipment;
use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory as TrackCollectionFactory;
class FindTackingInfo
{
/** @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection */
protected $trackingCollection;
public function __construct(TrackCollectionFactory $collectionFactory)
{
$this->trackingCollection = $collectionFactory->create();
}
public function getShipmentDetailsFromOrderId($orderId)
{
try {
$this->trackingCollection
->addFieldToFilter('order_id', $orderId); //123 is the order id
/** @var Shipment\Track $tracking */
$tracking = $this->trackingCollection->getFirstItem();
/** @var Shipment $shipment */
$shipment = $tracking->getShipment();
return $shipment->getData();
}
catch (\Magento\Framework\Exception\LocalizedException $e) {}
return null;
}
}
if issue solved, Click Kudos/Accept as solutions.
Suman Kar(suman.jis@gmail.com) Magento Certified Developer Plus Skype: sumanphptech Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.