Magento 1.7.0.2 SOAP API Bug using the Customer.update method

Source: Internet
Author: User
Tags session id

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.