Customer Resource
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”
Note: password_hash will only match exactly with the same MD5 and salt as was used when Magento stored the value. If you try to match with an unsalted MD5 hash, or any salt other than what Magento used, it will not match. This is just a straight string comparison.
customer.create |
Create customer
Return: int
Arguments:
- array customerData - customer 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 |
- $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
- $sessionId = $proxy->login('apiUser', 'apiKey');
- $newCustomer = array(
- 'firstname' => 'First',
- 'lastname' => 'Last',
- 'email' => 'test@example.com',
- // for my version of magento (1.3.2.4) you SHOULD NOT
- // hash the password, as in:
- // 'password_hash' => 'password'
- 'password_hash' => md5('password'),
- // password hash can be either regular or salted md5:
- // $hash = md5($password);
- // $hash = md5($salt.$password).':'.$salt;
- // both variants are valid
- 'store_id' => 0,
- 'website_id' => 0
- );
- $newCustomerId = $proxy->call($sessionId, 'customer.create', array($newCustomer));
- // Get new customer info
- var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
- // Update customer
- $update = array('firstname' => 'Changed Firstname');
- $proxy->call($sessionId, 'customer.update', array($newCustomerId, $update));
- var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
- // Delete customer
- $proxy->call($sessionId, 'customer.delete', $newCustomerId);


