Add Magento Admin User Using MySQL Script

How to add Magento Admin User Using MySQL Script ?

Here is the very simple answer to this question. This script quickly adds a Magento Admin user directly into the database. It is possible to run this script from the command line or by copying and pasting into phpMyAdmin. Most of these fields are trivial, I’m just listing them so you don’t miss anything.

  1. Set the salt portion of your password. You’ll rarely need to change this. If you do, just use two lower case letters of your choice.
  2. Set your password. At least 8 characters in length and at least one digit.
  3. Firstname: Enter admin’s first name.
  4. Lastname: Enter admin’s last name.
  5. Enter email of admin user.
  6. Enter username where ‘myuser’ is set. Notice ‘myuser’ shows up in two places.
  7. Enter Firstname again. This is more symbolic to label the rule.
LOCK TABLES `admin_role` WRITE , `admin_user` WRITE;
SET @SALT = "sid";
SET @PASS = CONCAT(MD5(CONCAT( @SALT , "password") ), CONCAT(":", @SALT ));
SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;
INSERT INTO `admin_user` (firstname,lastname,email,username,password,created,lognum,reload_acl_flag,is_active,extra) 
VALUES ('Firstname','Lastname','','myuser',@PASS,NOW(),0,0,1,@EXTRA);
INSERT INTO `admin_role` (parent_id,tree_level,sort_order,role_type,user_id,role_name) 
VALUES (1,2,0,'U',(SELECT user_id FROM admin_user WHERE username = 'myuser'),'Firstname');

And you’re done. Now you can login to your admin.. 🙂

Source: Activo

Display Category Images in Navigation

To display the images of categories in the main navigation menu, we need to update two files.

Firstly in Model file. (/app/code/core/Mage/Catalog/Model/Observer.php)

Update following code in Function Name: _addCategoriesToMenu

$categoryData = array( 
        'name' => $category->getName(),
        'id' => $nodeId,
        'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
        'is_active' => $this->_isActiveMenuCategory($category),
        'thumbnail' => Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()

Then go into Html folder. (app/code/core/Mage/Page/Block/Html/Topmenu.php)

Update the following line of code at line 128 in

Function name: _getHtml

$urls = Mage::getBaseUrl('media').'catalog/category/'.$child->getData('thumbnail');
$img = '<img src="'.$urls.'" />';

$html .= '
  • _getRenderedMenuItemAttributes($child) . '>'; $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '>' . $this->escapeHtml($child->getName()) . ' '.$img.' </a>';
  • Display product count of a category in main navigation

    To display Product Count of a particular category in the main navigation, just include the following code in function _addCategoriesToMenu() of the observer file. The Observer file is located at appcodecoreMageCatalogModelObserver.php

    $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
    			$prodCount = $prodCollection->count();
    				$prodCounts = '';
    				$prodCounts = ' ('.$prodCount.')';
    			$categoryData = array(
                    'name' => $category->getName().$prodCounts,
                    'id' => $nodeId,
                    'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
                    'is_active' => $this->_isActiveMenuCategory($category),
    				'thumbnail' => Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()

    Continue reading

    Currency switcher in magento left or right sidebar

    Need to show the drop down of currency in the sidebar ?

    Below code will displays the currency drop down on left and right sidebar.
    Open the directory.xml file in the layout folder (app/design/frontend/default/default/layout/directory.xml) and add the following code to it.

    <!– Mage_Catalog –>
    <reference name=”left”>
    <block type=”directory/currency” name=”currency” before=”cart_sidebar” template=”directory/currency.phtml”/>
    <reference name=”right”>
    <block type=”directory/currency” name=”currency” before=”cart_sidebar” template=”directory/currency.phtml”/>

    Comment the other node as show below Continue reading

    Creating A Magento Module

    A lot of community extensions (or modules) are available for the feature-rich open-source e-commerce solution Magento, but what if they don’t quite work as you want them to? Want to write your own module?

    In this tutorial, we will introduce the coding of Magento in the form of a “Hello World”-style module. The goal of the module will be simply to write some information to a log file every time a product is saved. This very basic module will allow us to cover a number of interesting topics, including: Continue reading