Magento

eCommerce Software for Online Growth

Customer Resource

Last modified by waltaskew on Wed, January 27, 2010 17:09
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)
  • 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.     //for my version of magento (1.3.2.4) you SHOULD NOT
  13.     // hash the password, as in:
  14.     // 'password_hash' => 'password'
  15.     'password_hash'   => md5('password'),
  16.     // password hash can be either regular or salted md5:
  17.     // $hash = md5($password);
  18.     // $hash = md5($salt.$password).':'.$salt;
  19.     // both variants are valid
  20.     'store_id'   => 0,
  21.     'website_id' => 0
  22. );
  23.  
  24. $newCustomerId = $proxy->call($sessionId, 'customer.create', array($newCustomer));
  25.  
  26. // Get new customer info
  27. var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
  28.  
  29.  
  30. // Update customer
  31. $update = array('firstname'=>'Changed Firstname');
  32. $proxy->call($sessionId, 'customer.update', array($newCustomerId, $update));
  33.  
  34. var_dump($proxy->call($sessionId, 'customer.info', $newCustomerId));
  35.  
  36. // Delete customer
  37. $proxy->call($sessionId, 'customer.delete', $newCustomerId);



 

Magento User Guide

Magento Enterprise Available now

Professional Services from the Magento Team

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs
© Copyright 2010 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
177522 users|1160 users currently online|277046 forum posts