2

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);
  • Just making sure. You did set up an api user/role correct? – Steven Lynn Aug 13 '14 at 19:32
  • @StevenLynn Yes My API User And Role is setup but I keep getting this error... – user1704524 Aug 13 '14 at 19:34
5

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);
  • Thanks for your reply, I wish it were that simple :D I've been trying for hours... I'm thinking that I may need to add an include into the file to get access to the salesOrderInfo method or summick – user1704524 Aug 13 '14 at 19:49
  • Did you try that code? – Steven Lynn Aug 13 '14 at 19:49
  • 2
    There is no include you have to add to the file. – Steven Lynn Aug 13 '14 at 19:51
  • 2
    Just to clarify you used the bottom section? I am having a hard to believing it didn't work. Do you have soap installed on your server? – Steven Lynn Aug 13 '14 at 19:54
  • 1
    I updated my code once more. Try it and let me know if it works. – Steven Lynn Aug 13 '14 at 21:27

Your Answer

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

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