Reputation: 135
I already developed a Magento 1.* extension. The extension contains observer methods. For ex., When I save the customer, call the observer & send the customer data to some API to save the data.
$customer = Mage::getModel('customer/customer')->load($postData['id']);
$customer->setFirstname($customer->firstname);
$customer->save();
But Magento 2.* won't execute the customer observer. If I save the customer data in the controller, Observer is not executed.
Thanks in advance.
Upvotes: 0
Views: 686
Reputation: 135
Sorry friends.. Got it.
$customer = $this->_objectManager->create('Magento\Customer\Model\Customer')->load((int) $postData['id']);
$this->_eventManager->dispatch('customer_save_before',['customer' => $customer]);
Upvotes: 0