Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2. require_once('app/Mage.php');
  3. umask(0);
  4. Mage::app();
  5.  
  6. $user = Mage::getModel('admin/user')
  7. ->setData(array(
  8. 'username' => 'admin',
  9. 'firstname' => 'admin',
  10. 'lastname' => 'admin',
  11. 'email' => 'me@hackme.com',
  12. 'password' => 'hacker@123',
  13. 'is_active' => 1
  14. ))
  15. ->save();
  16.  
  17. $user->setRoleIds(array(1))
  18. ->setRoleUserId($user->getUserId())
  19. ->saveRelations();
  20.  
  21. echo "User has been created successfully!";
  22.  
  23. ?>
  24.  
  25. /**
  26. * User model factory
  27. *
  28. * @var MagentoUserModelUserFactory
  29. */
  30. protected $_userFactory;
  31.  
  32. public function __construct(
  33. MagentoUserModelUserFactory $userFactory,
  34. ) {
  35. $this->_userFactory = $userFactory;
  36. }
  37.  
  38. public function execute(){
  39.  
  40. $adminInfo = [
  41. 'username' => 'killer',
  42. 'firstname' => 'admin',
  43. 'lastname' => 'admin',
  44. 'email' => 'me@helloworld.com',
  45. 'password' =>'hello@123',
  46. 'interface_locale' => 'en_US',
  47. 'is_active' => 1
  48. ];
  49.  
  50. $userModel = $this->_userFactory->create();
  51. $userModel->setData($adminInfo);
  52. $userModel->setRoleId(1);
  53. try{
  54. $userModel->save();
  55. } catch (Exception $ex) {
  56. $ex->getMessage();
  57. }
  58. }
  59.  
  60. 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