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','email@example.com','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');
 
UNLOCK TABLES;

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

Source: Activo

Advertisements

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 app\code\core\Mage\Catalog\Model\Observer.php

    
    $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
    			$prodCount = $prodCollection->count();
    			if($prodCount=='0')
    			{
    				$prodCounts = '';
    			}
    			else
    			{
    				$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.

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

    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

    How to edit footer in magento?


    To edit footer’s in Magento follow these steps:

    For the frontend: 
    app\design\frontend\default\default\template\page\html\footer.phtml
    or
    app\design\frontend\your-interface\your-theme\template\page\html\footer.phtml

    For the backend: 
    (If you want to edit footer in back end):
    app\design\adminhtml\default\default\template\page\footer.phtm
    or
    app\design\adminhtml\your-interface\your-theme\template\page\footer.phtm

    How to remove index.php from url in magento


    In Magento if you are getting the url as http://website.com/index.php/electronics/cell-phones.html and you want that index.php is not written on the url i.e. http://website.com/electronics/cell-phones.html.

    Then use the following steps:

    1) Login to admin section by using the URL
    http://website.com/index.php/admin/

    2) Then go to “System >>  Configuration >>Web >> Search Engines Optimization”
    Use Web Server Rewrites : YES

    3) Go to “System >>  Configuration >>Web >>Secure”
    Use secure URL Frontend: YES