Magento 1.8 – How to Get Order Info Using SOAP API

apimagento-1.8sales-ordersoap

I am trying to make a simple API call to get some information on an Order. The reason I am trying with SOAP is because a similar API request is returning empty values for some sales attributes so I am trying to see if I get a different result using SOAP but I keep getting

Fatal error: Call to a member function salesOrderInfo() on a non-object in

I've followed the information on the Magento WIKI

Here

But I keep getting this error, I've placed this file in the root of my Magento installation:

orderinfo.php

<?php

    $proxy = new SoapClient('http://www.mydomain.com/index.php/api/v2_soap?wsdl=1');

    $session = $proxy->login('user', 'password'); // connect to the API

    $result = $client->salesOrderInfo($session, '100000064');
    var_dump($result);

Best Answer

Simple error. You are using the wrong variable in SalesOrderInfo.

Your current code

Notice: That you set the session Id to $session, but then use $sessionId in salesOrderInfo.

<?php

$proxy = new SoapClient('http://www.mydomain.com/index.php/api/v2_soap?wsdl=1');

$session = $proxy->login('user', 'password'); // connect to the API

$result = $client->salesOrderInfo($sessionId, '100000064');
var_dump($result);

Edit: Another error. $client should be $proxy

Try the following code. This worked for me! Just add your url, and api username and password.

<?php

 $proxy = new SoapClient('http://www.mydomain.com/api/v2_soap/?wsdl'); 

 $session = $proxy->login('user', 'password'); 

 $result = $proxy->salesOrderInfo($session, '100000064');

 var_dump($result);
Related Topic