2

I want to create an observer in my custom module which called when new customer create and delete.

In my custom module i want to add custom data when customer created and delete custom data when customer deleted even its created from admin or imported.

How can i achieve this functionality.

Thanks.

  • i want to perform some action on customer save. – Utsav Gupta Dec 12 '18 at 12:01
3

For Save You can use this event customer_save_after when triggered you will get following below data.

customer_save_after => data_object(object), customer(object)

In Observer you can get customer data by

$observer->getEvent()->getCustomer();

For Delete You can use

customer_delete_after => data_object(object), customer(object)

Note: You can use before or after as per your requirement.

  • I search for events but I don't find same event. there are other events you can check here : blog.mdnsolutions.com/magento-2-list-of-all-events – Utsav Gupta Dec 13 '18 at 13:54
  • This events are available. Did you try using this event? – Priyank Dec 13 '18 at 14:03
  • yes i am trying but still no success. i tried with "adminhtml_customer_save_after" and "customer_save_after_data_object" events. – Utsav Gupta Dec 14 '18 at 5:12
  • use customer_save_after event it should work. – Priyank Dec 14 '18 at 5:31
  • could you please post whole example.? – Utsav Gupta Dec 14 '18 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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