I want to integrate sms trigger on sales_order_shipment_track_save_after event. I have created a custom module and the trigger is being called but I am not able to get orderid from shipment. Following is the code from my observer.

$shipment = $observer->getEvent()->getShipment();
        $order = $shipment->getOrder();
        $orderId = $order->getIncrementId();

but I keep on getting

Fatal error: Call to a member function getOrder() on a non-object in C:\xampp\htdocs\company\app\code\local\Company\Smstrigger\Model\Observer.php on line 11

can someone please point me to correct code for the same.

Magento version 1.9

1 Answer 1


Try this one. Shipment object is in track key.

  $event = $observer->getEvent();
  $track = $event->getTrack();
  $shipment = $track->getShipment();
  $order = $shipment->getOrder();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.