For an extension I need to create an api user programmatically using php. I use the following code:
$apiKey = '12345678';
$user = Mage::getModel('api/user');
$user->setData(array(
'username' => 'api_consumer',
'firstname' => 'fist',
'lastname' => 'last',
'email' => '[email protected]',
'new_api_key' => $apiKey,
'api_key_confirmation' => $apiKey,
'is_active' => 1,
'user_roles' => '',
'assigned_user_role' => '',
'role_name' => '',
'roles' => array($role->getId())
));
$user->save()->load($user->getId());
When I look in the database the api_key field is not filled, it has the value 'NULL'.
Is it possible to persist the api key?
I madfe a casing mistake, above code works, but I changed
'new_api_key' => $apiKey,
to
'api_key' => $apiKey,