I'm using the following example from Magento api to check for a specific customer:
$client = new SoapClient('http://localhost/magento/api/v2_soap/?wsdl');
$session = $client->login('fakeuser', 'fakepass');
$complexFilter = array(
'complex_filter' => array(
array(
'key' => 'email',
'value' => array('key' => 'in', 'value' => 'thecustomer@imlookingfor.com')
)
)
);
$result = $client->customerCustomerList($session, $complexFilter);
if (empty($result)) {
echo "no customer found";
} else {
var_dump($result);
// echo $result[0]->stdClass->fistname; // code in question
}
here's the response I'm getting
array(1) {
[0]=>
object(stdClass)#2 (10) {
["customer_id"]=>
int(52)
["created_at"]=>
string(19) "2014-09-14 03:08:27"
["updated_at"]=>
string(19) "2014-09-14 03:08:28"
["store_id"]=>
int(1)
["website_id"]=>
int(1)
["created_in"]=>
string(18) "Default Store View"
["email"]=>
string(21) "thecustomer@imlookingfor.com"
["firstname"]=>
string(6) "John"
["lastname"]=>
string(10) "Doe"
["group_id"]=>
int(1)
}
}
what I'm trying to do is echo out the customer's first name. I tried this:
echo $result[0]->stdClass->fistname;
but I'm getting these errors.
Notice: Undefined property: stdClass::$stdClass in /Users/sergey/Desktop/andagain/control-panel/check-if-customer-exists.php on line 24
Notice: Trying to get property of non-object in /Users/sergey/Desktop/andagain/control-panel/check-if-customer-exists.php on line 24
What am I missing?
Best Answer
You are accessing the property in wrong manner so it will give you error. try below one.
When you try to access the data using SOAP then
Let me know If any comments.