Question

Controller file

$collection = $this->investmentFactory->create()->load($id);
        $collection->getData();

        // echo '<pre/>';
        // print_r($collection->getData());
        $this->eventManager->dispatch('trigger_order_place',['collection', $collection]);
        exit;

In this observer file data is null

$collection = $observer->getEvent()->getCollection();
        var_dump($collection);
        
Was it helpful?

Solution

I think the problem is that you must pass key => value and you pass like two array items. Here is from core code.

        $this->eventManager->dispatch(
            'sales_order_payment_capture',
            ['payment' => $payment, 'invoice' => $invoice]
        );

Try changing to

$this->eventManager->dispatch('trigger_order_place',['collection' => $collection]);

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top