We will now look at how to view a full list of clients' IDs. We could display more information and customize it…but we'll take a look at that later in this tutorial.
To retrieve an XML file containing all the customers we have to use the "get" method whose array is as follows:
$opt[ 'resource' ] = 'customers'; $xml = $webService->get( $opt );
The value defines the resource that the web service will use in a future call. The value could be carrier types, countries or any other type of resource that can be found in the Web Service tab of the "Back Office".
Calling the method will return us to a SimpleXML object containing all client IDs.
<?xml> <prestashop> <customers> <customer> Client ID </customer> ...Other client tags </customers> </prestashop>
Now we need to access the tags that interest us in the XML file.
By getting the return of
$webService->get, we are at the root of the document.
$resources = $xml->customers->children();
To access the fields of clients who are children from the Customers tag, we only need to retrieve all fields in an associative array in SimpleXML like this:
From there we can access client IDs easily. Here's an example with a path from identifiers:
foreach ( $resources as $resource ) echo $resource->attributes() . '<br />';
Thanks to these elements, you create a HTML table containing all the customers' IDs before going on to the next chapter.
You can use the "customers" tab in the Back Office to find the IDs of all customers. If you encounter difficulties, please look at the file code
0-CustomersList.php for the results you should get.