1

I am trying to observe the data being passed when an admin creates a new order in the backend. I do not want to observe front end orders that are being created.

I currently have the following:

etc/config.xml

....
     <events>
         <sales_order_save_after>
            <observers>
                <modulename_order_new>
                    <class>module_name/observer</class>
                    <method>handleCustomerFirstOrder</method>
                </modulename_order_new>
            </observers>
        </sales_order_save_after>
     </events>
....

Module_Name_Model_Observer

public function handleCustomerFirstOrder($observer)
{
    $order = $observer->getEvent()->getOrder();
    Mage::Log('Order Info: ' . $order);
}  

So far I am unable to even print the log to see what it contains. I get the following:

*Recoverable Error: Object of class Mage_Sales_Model_Order could not be converted to string*

I have even tried:

Mage::Log('Order Info: ' . print_r($order));

But that does not work either.

I am needing to observe when the admin creates a new order and capture the data. Specifically the customer ID, Order #, and item product Id #'s.

Any help would be greatly appreciated.

Thanks

2

For the logging part you can for example use:

Mage::log('Order Info Start ------------------------');
Mage::log($order->debug());
Mage::log('Order Info End ------------------------');

For the other part of your question the following should be helpful:

$order->getIncrementId();

$order->getCustomerId();

foreach($order->getAllItems() as $item) {
    $item->getProductId();
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy