Why do i get this dispatch() on null error from my custom module

My error stack trace says:

Vendor\Module\Observer\SyncObserver->execute( ) ..\InvokerDefault.php:73

Vendor\Module\Model\Engine->productUpdate( ) ..\SyncObserver.php:35


namespace Vendor\Module\Observer;

use \Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class SyncObserver implements ObserverInterface
   protected $syncEngineFactory;

   protected $logger;

 function __construct
    \Vendor\Module\Model\Engine $syncEngineFactory      
    $this->syncEngineFactory = $syncEngineFactory;

 public function execute(\Magento\Framework\Event\Observer $observer)
    $event = $observer->getEvent();


  <event name="catalog_product_save_after">
    <observer name="catalog_product_save_after_handler" instance="Vendor\Module\Observer\SyncObserver"/>
  • Where is the dispatch() event which you want to catch? Aug 9, 2016 at 8:08
  • 1
    In my events.xml i have used as above updated answer
    – Sushivam
    Aug 9, 2016 at 8:46
  • Was this the event u were specifying @Khoa, or have i missed anything?
    – Sushivam
    Aug 9, 2016 at 10:13

1 Answer 1


Basically, you are wrong when getting the object from the event. In your case, we need to get the product object from the event: $product = $observer->getProduct().

  • Yes Khoa, in \Vendor\Module\Model\Engine, in productUpdate() i got the object as : $product = $observer->getEvent()->getProduct();
    – Sushivam
    Aug 9, 2016 at 12:36
  • But still why i get the same error
    – Sushivam
    Aug 9, 2016 at 12:36
  • Please, check your custom module and methods: saleOrderComplete, productUpdate and productDelete. Make sure they worked well. Aug 9, 2016 at 12:41
  • Currently, i have commented out Sales and productDelete events, wanted to check first if update event is working, but only for this single event, i face this issue..need suggestion
    – Sushivam
    Aug 10, 2016 at 5:41
  • Try to comment out the __constructor also, check only execute method. Remove var/generation and clear your Magento Cache again. Aug 10, 2016 at 15:43

Your Answer

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

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