0

I need to keep a log of customer attributes value changes. For every update on the user's account information, both from admin and frontend, I'm inserting a row in a flat log table with the old and the new value of every customer attribute that was changed. For this purpose I've created a custom module and implemented a pretty standard CRUD functionality to persist and manage all log entries. The next step is to find the appropriate location to capture customer attribute value update to hook my save logic . So far I've identified some potential locations but I'm not 100% sure it's they are the right ones:

\Magento\Customer\Model\Customer::updateData
\Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper::aroundSave 
(this is already a plugin)

Am I on the right path?

1 Answer 1

0
  1. for admin go with observer adminhtml_customer_save_after

  2. for user sign up make an around plugin for Magento\Customer\Controller\Account\CreatePost

2
  • I want to save the log entry only after I'm 100% that the change was saved in the database, so I think I need to go lower in the core functionality
    – Radu
    Commented May 22, 2019 at 9:21
  • but you need to use save after event then do your logging stuff in it Commented May 23, 2019 at 10:51

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.