通过magento中的soap客户端登录
我想通过soap客户端创建magento登录,这样我们就可以在magento中实现,通过magento中的soap客户端登录,magento,soap,Magento,Soap,我想通过soap客户端创建magento登录,这样我们就可以在magento中实现, 我从这个文件在magento根文件夹中创建了一个文件,我要在调用这个文件时提供soap登录功能,我不想让这个特定文件具有magento登录功能 这也可以与Magento分开运行,只需要存在app/Mage.php路径 <?php /* * Create New Admin User * @author Ivan Weiler, Inchoo <web@inchoo.net> */
我从这个文件在magento根文件夹中创建了一个文件,我要在调用这个文件时提供soap登录功能,我不想让这个特定文件具有magento登录功能 这也可以与Magento分开运行,只需要存在app/Mage.php路径
<?php
/*
* Create New Admin User
* @author Ivan Weiler, Inchoo <web@inchoo.net>
*/
//define USERNAME, EMAIL and PASSWORD and uncomment(#) this 3 lines
#define('USERNAME','inchoo');
#define('EMAIL','xyz@inchoo.net');
#define('PASSWORD','inchoo555');
if(!defined('USERNAME') || !defined('EMAIL') || !defined('PASSWORD')){
echo 'Edit this file and define USERNAME, EMAIL and PASSWORD.';
exit;
}
//load Magento
$mageFilename = 'app/Mage.php';
if (!file_exists($mageFilename)) {
echo $mageFilename." was not found";
exit;
}
require_once $mageFilename;
Mage::app();
try {
//create new user
$user = Mage::getModel('admin/user')
->setData(array(
'username' => USERNAME,
'firstname' => 'John',
'lastname' => 'Doe',
'email' => EMAIL,
'password' => PASSWORD,
'is_active' => 1
))->save();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
try {
//create new role
$role = Mage::getModel("admin/roles")
->setName('Inchoo')
->setRoleType('G')
->save();
//give "all" privileges to role
Mage::getModel("admin/rules")
->setRoleId($role->getId())
->setResources(array("all"))
->saveRel();
} catch (Mage_Core_Exception $e) {
echo $e->getMessage();
exit;
} catch (Exception $e) {
echo 'Error while saving role.';
exit;
}
try {
//assign user to role
$user->setRoleIds(array($role->getId()))
->setRoleUserId($user->getUserId())
->saveRelations();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
echo 'Admin User sucessfully created!<br /><br /><b>THIS FILE WILL NOW TRY TO DELETE ITSELF, BUT PLEASE CHECK TO BE SURE!</b>';
@unlink(__FILE__);
要创建Magento登录名;客户还是管理员?MagentoAPI不支持创建管理员用户,只支持创建客户实体。我有代码可以做到这一点,但您不能使用API。我很快就会把它寄出去。