Magento – how to get customer information using event observer

event-observermagento-1.9

I have already posted a question regarding this,
how to update customer and order details from magento to ERP using event observer?

my files are as follows:

Config.xml [app/code/local/Wli/Checkoutdemo/etc]

    <config>
  <modules>
    <Wli_Checkoutdemo>
      <version>0.1.0</version>
    </Wli_Checkoutdemo>
  </modules>
  <global>
  <events>
    <sales_order_place_after>
      <observers>
        <Wli_Checkoutdemo_sales_order_place_after>
          <type>singleton</type>
          <class>Wli_Checkoutdemo_Model_Observer</class>
          <method>Checkoutdemo</method>
        </Wli_Checkoutdemo_sales_order_place_after>
     </observers>
    </sales_order_place_after>
  </events>
  </global>
</config>

Wli_Checkoutdemo.xml[app/etc/modules]

<?xml version="1.0"?>
<config>
  <modules>
    <Wli_Checkoutdemo>
      <active>true</active>
     <codePool>local</codePool>
    </Wli_Checkoutdemo>
  </modules>
</config>

Observer.php [app/code/local/Wli/Checkoutdemo/Model]

<?php

class Wli_Checkoutdemo_Model_Observer {

    public function Checkoutdemo(Varien_Event_Observer $observer) {
        $event = $observer->getEvent();
        $customer = $event->getCustomer();
        $order = $event->getOrder();
        print_r($order);
        exit();
    }

}

I need to get the details which are entered by the customer here.

after placing the order I didn't get anything?

what's wrong here?

what are the steps I have to follow here?
(I am new to Magento, if anyone has any idea pls share here)

Best Answer

You can get a lot of customer details directly from the order object

$order->getCustomerEmail();
$order->getCustomerFirstname();

etc... You can see a lot of them by looking at the class comments in app/code/core/Mage/Sales/Model/Order.php

But you can also get the customer object from the order too like so

$customer = $order->getCustomer();
Related Topic