When updating user information using the SOAP API of Magento (1.7.0.2), it is not possible to update the user's password.
Let's start by looking at how to invoke the API update user information (refer to: Magentocommerce)
<?PHP$API_URL_V1 = "http://192.168.1.162/trunk/index.php/api/soap/?wsdl"; $username = ' Moshi '; $password = ' Moshipass ';//Connect soap$client = new SoapClient ($api _url_v1);//Get log in Session id$session_id = $client->login ($username , $password);//Invoke the method in the API $result = $client->call ( $session _id, ' customer.update ', Array ( ' customerId ' = > ' A ', ' customerdata ' + array (' firstname ' + ' Mo ', ' lastname ' = ' shi ', ' email ' = ' [email protected] ', ' group_id ' = ', ' password ' = ' 123456 ')); Var_dump ($result);? >
But this only does not update the user's password.
On-line approach:
Find File
app\code\core\mage\customer\model\customer\api.php
Modify the Update method in the code
$customer->save (); Add the code above:
if (Isset ($customerData [' Password '])) { $customer->setpassword ($customerData [' Password ']);}
Of course it's best to rewrite this module.
The approach I'm using is:
Modify the call function of the calling API
Change the password to Password_hash data (encrypted, of course)
We can find the code in the Update method of the API call Magento:
foreach ($this->getallowedattributes ($customer) as $attributeCode = = $attribute) { if (isset ($customerData [ $attributeCode]) { $customer->setdata ($attributeCode, $customerData [$attributeCode]);} }
This is actually based on the allowed properties to determine which properties of the value can be modified.
Print $attributeCode It is not possible to transmit password data directly without password.
But we can see that we can change the value of Pasword_hash.
Of course, to change this value, you need to know how your Magento system is encrypted in the first place.
Assuming that no changes have been made, the default encryption method is MD5 (Key+password)
So you just have to get the Password_hash value before calling $client->call ().
Magento 1.7.0.2 SOAP API Bug using the Customer.update method