Orders Event Observer API – How to Obtain JSON Order Rendered by REST API in Sales Order Place After Event

apievent-observerordersrest

I have an observer for the event "sales_order_place_after" that needs to take the order and transform it into a JSON object to be sent to an external system (over REST). However the JSON representation should be identical to the same order rendered by the REST API V2 (ie, only showing the attributes defined in api2.xml).

Is there any helper method that can do this?

Best Answer

first you will have to build an array as per your requirement than you can encode it be using it.

you can use below method for encoding array into json

$json = Mage::helper('core')->jsonEncode($array);