Jump to content

Why Cannot Get Other Attributes Except For Id When Using Api?


Ruoke

Recommended Posts

try
{
	$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
	$opt['resource'] = 'customers';
	
	// Call
	$xml = $webService->get($opt);
	echo "<pre>";
	echo var_dump($xml);
	
	// Here we get the elements from children of customers markup "customer"
	$resources = $xml->customers->children();
	
	if (isset($resources)){
		foreach ($resources as $resource)
		{
			echo var_dump($resource);
                        echo $resource->attributes();

		}
	}
	
}

And the result is

object(SimpleXMLElement)#2 (1) {
  ["customers"]=>
  object(SimpleXMLElement)#3 (1) {
    ["customer"]=>
    array(3) {
      [0]=>
      object(SimpleXMLElement)#4 (1) {
        ["@attributes"]=>
        array(1) {
          ["id"]=>
          string(1) "1"
        }
      }
      [1]=>
      object(SimpleXMLElement)#5 (1) {
        ["@attributes"]=>
        array(1) {
          ["id"]=>
          string(1) "2"
        }
      }
      [2]=>
      object(SimpleXMLElement)#6 (1) {
        ["@attributes"]=>
        array(1) {
          ["id"]=>
          string(1) "3"
        }
      }
    }
  }
}

There is nothing but "id" in the "@attributes", how can I get other data (e.g, last name, first name)? Thank you. Besides, it works well with the filter, that is when the given last name is set to the request, it only returns the specific customer, not all the customers.  

Edited by Ruoke (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...