3

I want to save a custom attribute value in my custom table after saving a customer from the admin panel, with an observer event, I only need the name of the event

  • 1
    When you want this observer at time of customer creation or customer save? – Amit Naraniwal Feb 8 at 9:12
4

You may use customer_save_after and eventually check if the action comes from admin if that's required

0

If you have tried to find out the event during customer creation at Magento, then you can use adminhtml_customer_save_after event.

            $this->_eventManager->dispatch(
                'adminhtml_customer_save_after',
                ['customer' => $customer, 'request' => $this->getRequest()]
            );

That this event, you get custom field data using $observer->getRequest()->getPostValue(); if you will add any custom field admin customer create and edit page.

Observer look Like:

<?php

namespace {VendorName}\{ModuelName}\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class SaveFromBackend implements ObserverInterface
{


    /**
     * Save A customer Annual Purchase Limit
     *
     * @param  Observer $observer
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function execute(Observer $observer)
    {

        $customer = $observer->getEvent()->getCustomer();
        $request = $observer->getEvent()->getRequest();
        $postData = $request->getPostValue();

        if (isset($postData['custom_field']))
        ) {
        $customfield = $postData['custom_field'];
            // Save data here
        }
    }
}
0

You can use customer_save_commit_after event as this is triggered after the transaction is committed.

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.