4

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)

  • What is actually the error/problem you are getting here? – David Manners Sep 2 '15 at 9:11
  • always dump data to log files , you can use Mage::log('Your custom log here'); dont use print_r and exit – inrsaurabh Oct 16 '17 at 6:19
4

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();
1

The event sales_order_place_after sends the order and only the order during the dispatch process.

Mage::dispatchEvent('sales_order_place_after', array('order'=>$this));

This means that your code $customer = $event->getCustomer(); will not return anything. But you should be able to get the complete order information from $order = $event->getOrder();

This will give you a model of type Mage_Sales_Model_Order which will contain all the information about the order itself. From this model you should be able to get anything you need to know about the order.

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.