Actually, I am trying to get customer data in observer and my event is
"adminhtml_customer_save_after"
I have made observer
Code:-
<?php
/**
* Copyright � 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Amitshree\Customer\Observer;
use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;
class Customersaveafter implements ObserverInterface
{
protected $_request;
protected $_layout;
protected $_objectManager = null;
protected $_customerGroup;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Framework\ObjectManagerInterface $objectManager
) {
$this->_layout = $context->getLayout();
$this->_request = $context->getRequest();
$this->_objectManager = $objectManager;
}
/**
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(EventObserver $observer)
{
echo "<pre>";
$event = $observer->getEvent();
$customer = $event->getCustomer();
print_r($customer->getData());
die('Observer Is called!');
}
}
I want to get Customer infromation and i am trying to print customer in this file using
$event = $observer->getEvent();
$customer = $event->getCustomer();
print_r($customer->getData());
but don't get any result.
I have created events.xml in etc/adminhtml/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adminhtml_customer_save_after">
<observer name="Amitshree_Customer_Customer_Save_After" instance="Amitshree\Customer\Observer\Customersaveafter" />
</event>
</config>