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.

1
  • i want to perform some action on customer save. Dec 12, 2018 at 12:01

1 Answer 1

4

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.

8
  • 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 Dec 13, 2018 at 13:54
  • This events are available. Did you try using this event?
    – Priyank
    Dec 13, 2018 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. Dec 14, 2018 at 5:12
  • use customer_save_after event it should work.
    – Priyank
    Dec 14, 2018 at 5:31
  • could you please post whole example.? Dec 14, 2018 at 5:43

Your Answer

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

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