Next Webinar: Maximizing Magento - Get the Most out of Promotions. Register Today!

Magento

Open Source eCommerce Evolved

Customer Resource

Last modified by Michael on Thu, August 7, 2008 13:43
Source|Old Revisions  

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)

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 (optional) - return only this attributes

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 not exists.
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'));
  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);



 

Popular Wiki Tags  |  View all

 jQuery   schema   diagram   db   database   cache   block   clienti magazin   model   observer   pdf   upload   video   image   default 

Professional Services from the Magento Team

Professional Installation from the Magento Team

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
39941 users|437 users currently online|85989 forum posts