Magento XML-RPC customer.create

I ran into an issue where the SOAP API just stopped working. Turns out that was down, and the SOAP API references it. So, in order to get rid of this additional third party dependency, I have been trying to rewrite our communication bridge using the XML-RPC API instead.

For the past 24 hours I have been fighting with the Magento XML-RPC API, thinking that it was the API that was flaky, but it turns out the issue was with Zend_XmlRpc auto-conversion.

Now for the juicy party. To get the XML request to be correctly formatted you need to force the associative array to be a Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT and wrap it in an array().

// Create new customer
$new_customer = array(
            'firstname'     => $first_name,
            'lastname'      => $last_name,
            'email'         => $email,
            'password_hash' => $password,
            'store_id'      => 0,
            'website_id'    => 0

$new_customer_id = $this->client->call('call', array($this->session, 'customer.create', array(Zend_XmlRpc_Value::getXmlRpcValue($new_customer, Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT))));

Related Posts