<?php error_reporting(E_ALL | E_STRICT); $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); umask(0); Mage::app('default');//if you changed the code for the default store view change it here also Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID)); $username = 'yourUsername';//desired username $firstname = "Firstname";//desired firstname $lastname = "Lastname";//desired lastname $email = "email@example.com";//desired email $pass = 'yourPaSSWordHere';//desired password $user = Mage::getModel('admin/user')->load($username, 'username'); if ($user->getId()){ echo "User {$username} already exists"; exit; } $user->setUsername($username) ->setFirstname($firstname) ->setLastname($lastname) ->setEmail($email) ->setPassword($pass) ; $result = $user->validate(); if (is_array($result)){ foreach ($result as $res){ echo $res."\n"; } exit; } try{ $user->setForceNewPassword(true); $user->save(); $user->setRoleIds(array(1))->saveRelations(); echo "User {$username} was created"; exit; } catch (Exception $e){ echo $e->getMessage(); }Now call in you browser this url www.mysite.com/adminuser.php. You should see a message on the screen with the result of your action. Cheers, Marius.
Thursday, February 16, 2012
Create admin user by code
Here is a piece of code that will allow you to create admin users. It's really useful if you forget the admin password:
Create a file called adminuser.php on the same level as index.php (in the root of the application) with the following content:
Friday, February 10, 2012
Keep products in the wishlist after adding them to cart.
Here is an interesting question I found on the Magento forum:
Leave Wishlist as it is after adding item to shopping cart?
Here is what you can do.
Override the wishlist index controller (app/code/core/Mage/Wishlist/controllers/IndexController.php) or edit it if you don't care about keeping the core clean (I recommend to keep it clean though)
and inside the method cartAction() there is this line:
You can change the second parameter to false or remove it completely - it defaults to false.
Marius.
Leave Wishlist as it is after adding item to shopping cart?
Here is what you can do.
Override the wishlist index controller (app/code/core/Mage/Wishlist/controllers/IndexController.php) or edit it if you don't care about keeping the core clean (I recommend to keep it clean though)
and inside the method cartAction() there is this line:
$item->addToCart($cart, true);The second parameter of the method addToCart means 'Remove from wishlist'.
You can change the second parameter to false or remove it completely - it defaults to false.
Marius.
Subscribe to:
Posts (Atom)