Open oltreseba opened 9 years ago
Hi, I think that should work.
Please check the return value of \Mage_Customer_Model_Api_Resource::getAllowedAttributes()
during the SOAP method call, maybe using something like Mage::log()
. It should include the customer_activated
attribute.
Adding this code in the creation, after the saving:
foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
Mage::log($attributeCode, null, 'api.log');
}
Has produced the follwing lines in the log file:
2015-07-23T09:16:59+00:00 DEBUG (7): created_at
2015-07-23T09:16:59+00:00 DEBUG (7): updated_at
2015-07-23T09:16:59+00:00 DEBUG (7): increment_id
2015-07-23T09:16:59+00:00 DEBUG (7): store_id
2015-07-23T09:16:59+00:00 DEBUG (7): website_id
2015-07-23T09:16:59+00:00 DEBUG (7): agent_id
2015-07-23T09:16:59+00:00 DEBUG (7): companysector
2015-07-23T09:16:59+00:00 DEBUG (7): confirmation
2015-07-23T09:16:59+00:00 DEBUG (7): created_in
2015-07-23T09:16:59+00:00 DEBUG (7): customer_activated
2015-07-23T09:16:59+00:00 DEBUG (7): default_billing
2015-07-23T09:16:59+00:00 DEBUG (7): default_shipping
2015-07-23T09:16:59+00:00 DEBUG (7): disable_auto_group_change
2015-07-23T09:16:59+00:00 DEBUG (7): dob
2015-07-23T09:16:59+00:00 DEBUG (7): email
2015-07-23T09:16:59+00:00 DEBUG (7): firstname
2015-07-23T09:16:59+00:00 DEBUG (7): gender
2015-07-23T09:16:59+00:00 DEBUG (7): group_id
2015-07-23T09:16:59+00:00 DEBUG (7): lastname
2015-07-23T09:16:59+00:00 DEBUG (7): middlename
2015-07-23T09:16:59+00:00 DEBUG (7): password_hash
2015-07-23T09:16:59+00:00 DEBUG (7): prefix
2015-07-23T09:16:59+00:00 DEBUG (7): rp_token
2015-07-23T09:16:59+00:00 DEBUG (7): rp_token_created_at
2015-07-23T09:16:59+00:00 DEBUG (7): suffix
2015-07-23T09:16:59+00:00 DEBUG (7): taxvat
2015-07-23T09:16:59+00:00 DEBUG (7): vatno
So apparently it's inside the attribute list, but still it's not managed properly.
Loggin the $customerData has produced the following information:
2015-07-23T09:21:26+00:00 DEBUG (7): stdClass Object
(
[email] => example@example.com
[firstname] => M****
[lastname] => C****
[password] => *****
[website_id] => 1
[store_id] => 1
[group_id] => 4
[dob] => 1970-04-03
[taxvat] => 0******3
)
customer_activated is not there, eve if it's included in the file that call the API.
$customer = array(
'email' => $customer['Mail'],
'firstname' => ucfirst(strtolower(trim($customer['name']))),
'lastname' => ucfirst(strtolower(trim($customer['surname']))),
'password' => trim($customer['password']),
'website_id' => 1,
'store_id' => 1,
'group_id' => $group,
'taxvat' => trim($customer['vat']),
'dob' => date('Y-m-d', strtotime(trim($customer['dob']))),
'customer_activated' => 1
);
$client->customerCustomerCreate($session, $customer);
What else should I check?
Please check the arguments that arrive in \Mage_Api_Model_Server_Handler_Abstract::call()
.
Does the $args
array contain the customer_activated
attribute`
If not, it is bound to be an issue with the WSDL not allowing that attribute.
It is not present in the call() function. I've added the attribute to wsdl file like here:
<element name="customer_activated" type="xsd:int" minOccurs="0" />
But still it's not showing up. Cleared cache and everything!
Are you using a PHP soap client? Did you clear the PHP level client WSDL cache?
$client = new SoapClient('http://somewhere.com/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE) );
It is already added. Now, for not apparently reason the customer_activated field is sent and receivedby the API, but still it is not saved.
Any idea?
Thanks
No idea, no. As long as the attribute code is returned by \Mage_Customer_Model_Api_Resource::getAllowedAttributes()
, I can't see a reason why \Mage_Customer_Model_Customer_Api::update()
wouldn't save it.
All I can suggest is to debug further to find the place it is skipped.
LOL. The issue is that i've set in the configuration "Activate new Customer Accounts by Default" to NO. So new created account using the APIs are set to not activated even if i've manually set the activation code to 1. My idea is that using the API this default value should not be applied, because API are more likely used by the website admin.
How can i by-pass the check only if the creation is required by the APIs?
Should i Change customerSaveBefore() method from:
$customer->setCustomerActivated($defaultStatus);
to
if (!$this->_isApiRequest()) {
$customer->setCustomerActivated($defaultStatus);
}
Great find. I've just pushed a new version including that check (see https://github.com/Vinai/customer-activation/blob/master/app/code/community/Netzarbeiter/CustomerActivation/Model/Observer.php#L433-L443). Can you please let me know if that resolves the issue for you? Thanks!
Hello, is there any way to update the user activation status (from not active, to active) using the user update api?
I'm trying the following but it seems like it's not working:
Thanks.