This is my first time trying to pull information with the Magento soap API. I have used SOAP previously on the Orange M2M connect server.

Ive hit a stump and im not sure where to go from here. I have managed to pull salesOrderList from Magento and var_dump them, and all the data is there. But when i try to access say the increment_id using the method below i get this error:

Cannot use object of type stdClass as array in C:\xampp\htdocs\magento_soap_client\fulfilment\soap\class.orders.php

Code used to try and get the increment id:

$this->m_orders = $this->client->salesOrderList($this->sessionID);

foreach($this->m_orders as $o){
            var_dump($o['increment_id']);
        }

Why am i getting this error?

I haven't parsed the data through an XML Parser yet, do i need to before accessing the information? The reason i ask is because this is what i had to do when working with the orange m2m connect soap server.

Thanks

up vote 1 down vote accepted

This means that $o is not an array. It's an instance of stdClass. Try like this:

var_dump($o->increment_id);

or

var_dump((array)$o['increment_id']);
  • Excellent thanks, the first option worked perfectly. Just out of interest, whats the preferred method? Thanks – Tom Burman Oct 20 '13 at 16:45
  • I prefer the first one. I try to use an object as it is. I don't cast it unless it's necessary – Marius Oct 20 '13 at 17:37

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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