Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To retrieve an XML file containing all the customers we have to use the "get" method whose array is as follows:

Key

Value

resource

customers

...

Code Block
 
$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". <span style="color: #0070c0">Example:</span>

Example

Calling the method will return us to a SimpleXML object containing all client IDs.

Code Block

<?xml>

...


<prestashop>

...


  <customers>
    <customer>
      Client ID
    </customer>

...


...Other client tags

...


  </customers>

...


</prestashop>

</xml>Now Now we need to access the tags that interest us in the XML file:.

Structure

...

By getting the return of "$ webService $webService->get, " we are at the root of the document.

Code Block

$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:

Code Block

foreach ( $resources as $resource )
  echo $resource->attributes() . '<br />'; 

Thanks to these elements, you create a HTML table (HTML) 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.