Customer Resource

Last modified by brobie on Mon, November 16, 2009 19:00
Source|Old Revisions  

This is an old revision of the document!


Allows to export/import customers from/to Magento

Module: Mage_Customer

Resource: customer

Methods

customer.list

Retrieve customers

Return: array

Arguments:

  • array filters - filters by customer attributes (optional)
  • filter list - “updated_at”, “website_id”, “increment_id”, “lastname”, “group_id”, “firstname”, “created_in”, “customer_id”, “password_hash”, “store_id”, “email”, “created_at”

customer.create

Create customer

Return: int

Arguments:

  • array customerData - cutomer data (email, firstname, lastname, etc...)

customer.info

Retrieve customer data

Return: array

Arguments:

  • int customerId - Customer ID.
  • array attributes | string attribute (optional depending on version) - return only these attributes. Possible attributes are updated_at, increment_id, customer_id, created_at. The value, customer_id, is always returned.

customer.update

Update customer data

Return: boolean

Arguments:

  • int customerId - customer ID
  • array customerData - customer data (email, firstname, etc...)

customer.delete

Delete customer

Return: boolean

Arguments:

  • int customerId - customer ID.

Faults

Fault Code Fault Message
100 Invalid customer data. Details in error message.
101 Invalid filters specified. Details in error message.
102 Customer does not exist.
103 Customer not deleted. Details in error message.

Examples

Example 1. Customer view/create/update/delete

  1. $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sessionId = $proxy->login('apiUser', 'apiKey');
  3.  
  4. // View all customers
  5. var_dump($proxy->call($sessionId, 'customer.list', array('filters', '*')));
  6.  
  7. // Create new customer
  8. $newCustomer = array(
  9.     'firstname'  => 'First',
  10.     'lastname'   => 'Last',
  11.     'email'      => 'test@example.com',
  12.     'password_hash'   => md5('password'),
  13.     // password hash can be either regular or salted md5:
  14.     // $hash = md5($password);
  15.     // $hash = md5($salt.$password).':'.$salt;
  16.     // both variants are valid
  17.     'store_id'   => 0,
  18.     'website_id' => 0
  19. );
  20.  
  21. $newCustomerId = $proxy->call($sessionId, 'customer.create', array($newCustomer));
  22.  
  23. // Get new customer info
  24. var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
  25.  
  26.  
  27. // Update customer
  28. $update = array('firstname'=>'Changed Firstname');
  29. $proxy->call($sessionId, 'customer.update', array($newCustomerId, $update));
  30.  
  31. var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
  32.  
  33. // Delete customer
  34. $proxy->call($sessionId, 'customer.delete', $newCustomerId);



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs