0

I am working on Admin Actions Log Extension. For the reference i am using link below

https://amasty.com/admin-actions-log-for-magento-2.html

I want to get old and new data of customer while we save customer data in admin.

I'm using customer_save_before event observer for customer

app/code/Vendor/Module/etc/adminhtml/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <event name="customer_save_before">
         <observer name="customer_save_before" instance="Vendor\Module\Observer\CustomerSaveBefore" />
      </event>
</config>

CustomerSaveBefore.php

class CustomerSaveBefore implements ObserverInterface
{

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        echo "<pre>";
        echo "xxxxxxxxxxxxxxxxx";
        $customer = $observer->getEvent()->getCustomer();
        var_dump($customer->getId());
        var_dump($customer->getData());
        // Need to get old customer data here
        exit();
    }
}

if anyone has a solution please let me know.

1

There is a problem with this particular event

Magento 2 origData null in customer_save_before

You are going to have to use a different event or code a workaround.

  • do you have any suggestions? – Mohit Rane Aug 8 '19 at 10:13

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.