cancel
Showing results for 
Search instead for 
Did you mean: 

Add Tracking Number with Soap

Add Tracking Number with Soap

Hi

 

I want to add the tracking number for my orders with soap.

 

Where can I find information how to do this?

 

Thank you in advance

 

Regards

1 REPLY 1

Re: Add Tracking Number with Soap

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'.