I am creating an extension on sales_order_place_after event observer & I want to get the Order & Customer Details with the following code, but I am not sure how to do this correctly.


    <?xml version="1.0"?>
                <sales_order_place_after><!-- observe the event -->


    class Avyam_Sms_Model_Observer {
        public function newFunction($observer) {
            Mage::log('The Product has been save', null, 'mylogfile.log');    

Please assist me, thanks in advance.

  • don't put to global tags in ur config.xml try to put <events></events> under first <global> tag after </model></model> and try Feb 3, 2015 at 13:17

1 Answer 1

$order = $observer->getEvent()->getOrder();
echo "<pre>"; print_r($order->getData());   // order details

$customer_id = $order->getCustomerId();
$customerData = Mage::getModel('customer/customer')->load($customer_id); // then load customer by customer id
echo "<pre>"; print_r($customerData->getData());    // ; add after echo "<pre>";  

In The $order->getData() you will get all order related data and in the $customerData->getData() you will get Customer data

add above code in your observer

  • thanks for help,how to print this info in log file, i am using this code Mage::log(print_r($order->getData()), null, 'mylogfile.log'); but not getting details in log file
    – Dinesh
    Feb 2, 2015 at 8:49
  • Mage::log($order->getData(),null,'mylog.log'); Feb 2, 2015 at 9:13
  • i used this,but it not working checkout page not redirect to success page show 500 internal error in browser console & nothing is printed in mylog.log file
    – Dinesh
    Feb 3, 2015 at 6:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.