Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('app/Mage.php');
- umask(0);
- Mage::app();
- $user = Mage::getModel('admin/user')
- ->setData(array(
- 'username' => 'admin',
- 'firstname' => 'admin',
- 'lastname' => 'admin',
- 'email' => 'me@hackme.com',
- 'password' => 'hacker@123',
- 'is_active' => 1
- ))
- ->save();
- $user->setRoleIds(array(1))
- ->setRoleUserId($user->getUserId())
- ->saveRelations();
- echo "User has been created successfully!";
- ?>
- /**
- * User model factory
- *
- * @var MagentoUserModelUserFactory
- */
- protected $_userFactory;
- public function __construct(
- MagentoUserModelUserFactory $userFactory,
- ) {
- $this->_userFactory = $userFactory;
- }
- public function execute(){
- $adminInfo = [
- 'username' => 'killer',
- 'firstname' => 'admin',
- 'lastname' => 'admin',
- 'email' => 'me@helloworld.com',
- 'password' =>'hello@123',
- 'interface_locale' => 'en_US',
- 'is_active' => 1
- ];
- $userModel = $this->_userFactory->create();
- $userModel->setData($adminInfo);
- $userModel->setRoleId(1);
- try{
- $userModel->save();
- } catch (Exception $ex) {
- $ex->getMessage();
- }
- }
- php bin/magento admin:user:create --admin-user="admin" --admin-firstname="Admin" --admin-lastname="A" --admin-email="admin@admin.com" --admin-password="admin@5252"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement