Updating Magento Order Status through an API call

I’ve written an integration between our backoffice system and magento – to update the status of orders in Magento.

I used the Microsoft MSXML2.ServerXMLHTTP object to send a post to the website – it’s basically requesting a URL and passing some parameters on the query string (ie order number, status etc).

The url might be something like:

On the server a php script at the URL requested handles the request and updates the order status – a very simple solution with no checks might be…

$mage_url = 'http://www.mywebsite.co.uk/api?wsdl';
$mage_user = 'apiuser';
$mage_api_key = 'apipassword';

// Initialize the SOAP client
$proxy = new SoapClient( $mage_url );

// Login to Magento
$session_id = $proxy->login( $mage_user, $mage_api_key );

//Get Parameters
$thisOrderId = $_GET['orderId'];
$thisStatus = $_GET['orderStatus'];

//Update Status
$proxy->call($session_id, 'sales_order.addComment', array($thisOrderId,$thisOrderStatus,'Updated through API', false));

Leave a Reply

Your email address will not be published. Required fields are marked *