Login as a customer from Magento admin

Often there are situations where customer has some issues while placing orders or making operations from the “My Account” section. At that point, an ability for admin to login as a customer and see what is wrong becomes very useful. Sure, you can make a universal password logic, but that method has heavy security risks. Not so long ago, we’ve noticed that Magento has ability to load and use customer’s sessions different way. We will tell you how to create a simple extension for logging in as a customer from Magento admin. Step 1 For example, let’s call our module Arun_Ulogin. As always we must start by creating a module descriptor in app/etc/modules folder. So put the Arun_Ulogin.xml file into this directory. The file will be with the following content:
<&#63xml version="1.0"?>

    
         
            true
            community
          
    

Overriding Magento observers

As you may know, we need to override the Magento observers when we deal with the extension’s conflicts or want to disable (or modify) a part of some extension’s functionality. Usually, there is no difference between the observer’s overriding and overriding of any other regular model. But sometimes we can face with the issues working with the simple override. How should we act then to keep it conventionally? Let’s check the following step by step instruction for Magento observers overriding. First of all, we should pay attention to the naming. Let’s assume that we have some 3rd party extension. It is named Some_Extension, and this extension has the following observer:
<&#63php
/**
 * file path:
 * magento_root/app/code/local/Some/Extension/Model/Observer.php
 */
 
class Some_Extension_Model_Observer
{
   public function someMethod( $observer )
   {
      /** 
       *Do some stuff here 
       */
         
      return $observer;
   }
}
&#63>

How to rewrite url in Magento

Follow these instruction to rewrite url. Step 1:- Make a new category named with "laptop" and save it. Step 2:- Go to Catalog->Url rewrite management.And find your newly created category and click on it. more instruction see in below pic.


Some useful and important code in magento

Some useful and important code in magento :-
<&#63php  
Magento Home URL 
- Mage::getBaseUrl();
 
Magento Home Directory 
- Mage::getBaseDir();
 
URL of a file in the skin directory
- $this->getSkinUrl('images/myfile.png'); // in a template or Block
- Mage::getDesign()->getSkinUrl('images/myfile.png'); // from anywhere
 
Format a price value
- Mage::helper('core')->formatPrice($amount);
 

How to insert,update,delete and show data in Magento

Suppose, I have a module named mynews. Here follows the code to select, insert, update, and delete data from the news table
1. INSERT DATA
$data contains array of data to be inserted. The key of the array should be the database table’s field name and the value should be the value to be inserted.
<&#63php
$data = array('title'=>'hello there','content'=>'how are you? i am fine over here.','status'=>1);
$model = Mage::getModel('mynews/mynews')->setData($data);
try {
    $insertId = $model->save()->getId();
    echo "Data successfully inserted. Insert ID: ".$insertId;
} catch (Exception $e){
 echo $e->getMessage();   
}
&#63>