If I observe customer_save_after
event I can get information about the customer with $customer = $observer->getEvent()->getCustomer();
.
However, if dispatching my custom event instead of customer_save_after
I get
Error: Call to a member function getDataModel() on null
when I try to get it like $customerData = $customer->getDataModel();
I think this is because I can't even get getCustomer()
in an custom event.
Is there anything I could do to get the same data as from customer_save_after
?
Edit: custom dispatch
public function afterAddCustomer()
{
$this->eventManager->dispatch(
'myname_customer_save_after',
['block' => $this]
);
}
Edit2: Changed the dispatcher but now I get
Error: Call to undefined method Vendor\Module\Plugin\Model\EventCompanyAccount::getDataModel()
I think getDataModel()
method can be found in \Magento\Customer\Model\Data\AttributeMetadata.php
but extending my class does not fix the error.