This tutorial is going to show you how to add and and manage Multiple Stores on your Magento website.
Multiple Stores functionality allows you to power any number of stores or websites within a single Magento installation. It can be useful if you are going to sell products on different domains sharing the same admin panel and to track your sales and customers without having to login to the admin area of each website.
There a number of different ways to enable the Multi-Store Functionality. This example shows how run two websiteswww.your_domain.com/magento/ and www.your_domain.com/magento/magento2 under the same admin area. But it will be also useful, if you are going to run the sites under two different domains as well.
Here are the steps to follow:

Step 1. Creating Categories:

  1. Log in to your Magento admin panel.
  2. Go to Catalog -> Manage Categories.
  3. If you want both your websites to share same “Default Category”, select it by clicking on it on the left. Or click Add Root Category to create a new root category different from the existing one.
  4. Once the category is selected, under the General Information set Is Active to Yes
    and under the Display Settings tab in the dropdown set Is Anchor to Yes.
  5. Click Save Category.

Step 2. Store Configuration

  1. Go to System -> Manage Stores
  2. Click the Create Website button
    where you need to enter:
    • Name – domain name of the new website
    • Code – a parameter that will be used in configuring the Apache web server to point to that particular domain name (without spaces)
  3. Click Save Website.
  4. Go to System -> Manage Stores and click the Create Store button.
  5. In the Website drop-down select the website the Name which you created before (2).
  6. Enter aName – the same as the second website name
  7. Select a Root Category in the drop-down– the root category that will be used for this store. (Refer to Step 1 for details)
  8. Click Save Store.
  9. Go to System -> Manage Stores and click the Create Store View button.
  10. In the Store drop-down select the store to which this view will be associated with.
  11. In the Name field enter a name of this store view (i.e. English Version).
  12. In the Code field enter a unique code for this store view.
  13. Select the Status – if enabled, this store view will be accessible from our frontend, otherwise, it will not be accessible
  14. Click Save Store View.

Step 3: Store Configuration in the Server

  1. In this tutorial we are going to see a second website at www.your_domain.com/magento/magento2. We are going to access the magentodirectory on our server and create a sub-directory folder magento2.
  2. Copy the index.php file as well as the htaccess file from the magento folder over to the magento2 folder. In case you are using a different domain – copy these files to the root folder or your other domain).
  3. Open your index.php file and look for the following line
    "$mageFilename = ‘app/Mage.php’;"
  4. Change it to
    $mageFilename = ‘../app/Mage.php’;
  5. Save the changes
  6. Open up the copied htaccess file.
  7. Add the following to the end of it
    SetEnvIf Host .*base.* MAGE_RUN_CODE="base";
    SetEnvIf Host .*magento_site_2.* MAGE_RUN_TYPE="magento2";
    where magento2 is the website code taken from Step2 point 2 of this tutorial.
  8. Save the changes.
  9. In your Magento admin go to System -> Configuration -> General.
  10. First, make sure that the Default Config is selected in the configuration scope and click Web
  11. Under the Url options set Auto-Redirect to base URl to No
  12. Click Save Config
  13. Change the Default Config to the to newly created website’s view in the configuration scope and click Web
  14. Under the Web click both the Unsecure and Secure tabs. You need to modify the Unsecure Base URL and Secure Base URLwith the corresponding domain name by unchecking the ”Use default [STORE VIEW]” checkbox and then save the configuration. In our case we are changing them this way (installed locally):
  15. Click Save Config
  16. Go to your second domain to check it out.
Hello Friends

If you want to get cart subtotal and quantity in Magento then you can use my below script

$items = Mage::getSingleton(‘checkout/session’)->getQuote()->getAllItems();

foreach($items as $item) {
echo ‘ID: ‘.$item->getProductId().’‘;
echo ‘Name: ‘.$item->getName().’‘;
echo ‘Sku: ‘.$item->getSku().’‘;
echo ‘Quantity: ‘.$item->getQty().’‘;
echo ‘Price: ‘.$item->getPrice().’‘;
echo ““;
}

Get total items and total quantity in cart :-

$totalQuantity = Mage::getModel(‘checkout/cart’)->getQuote()->getItemsQty();
Get subtotal and grand total price of cart :-
$subTotal = Mage::getModel(‘checkout/cart’)->getQuote()->getSubtotal();
$grandTotal = Mage::getModel(‘checkout/cart’)->getQuote()->getGrandTotal();

Get total prize with total item in cart:-


$count = $this->helper(‘checkout/cart’)->getSummaryCount();  //get total items in cart
$total = $this->helper(‘checkout/cart’)->getQuote()->getGrandTotal(); //get total price
?>
Hello Friends

If you want to Remove .html from URL in Magento then you can use my below method

If you want to remove .html from all Magento’s category URL then Follow the below steps

    Go to System -> Config -> Catalog -> Search Engine Optimizations tab
    Delete “.html” from Category URL Suffix.
    Go to System->Index Management
    Reindex “Catalog URL Rewrites”
    Refresh cache

If you want to remove  .html from all Magento’s product URL then steps will same.
Except 2. Delete “.html” from Product URL Suffix
Hello Friends

If you want to change the page tittle in Magento then you can use my below method,Which are given as follows:

(1) CMS page: Go to backend and open CMS > Manage Pages. Select page to edit and you can set title in ‘Page Title’ field.


(2) In frontend and any module, you can use xml file to set new title for your page. The syntax is:

<reference name=“header”>
    <action method=“setTitle” translate=“title”><title>Er-Keyur Shah</title></action>
</reference>


 (3) If it does not work, now you should look at your block php file. You might easily find this line:

<?php $this->getLayout()->getBlock(‘head’)->setTitle($title); ?>

Let me know if you have any query




Hello Friends

If you want to call phtml file from controller in magento then use my below script

<?php
class Namespace_Module_DisplayController extends Mage_Core_Controller_Front_Action
{
public function popupAction()
{
$block = $this->getLayout()->createBlock('core/template')
->setTemplate('zipcode/popup.phtml');
$this->getResponse()->setBody($block->toHtml());
}
}
?>
Hello Friends

If you want to get database details in magento then you can use my below script

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");
        $_host = $config->host;
        $_uname = $config->username;
        $_pass = $config->password;
        $_dbname = $config->dbname;
        echo $_host; 


Let me know if you have any query


Hello Friends

If you want to get order count of particular customer in magento from customer id then you can use my below script

$customer_id = 5;
$_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id);                      
$_orderCnt = $_orders->count(); //orders count
echo 'Customer with ID '.$customer_id.' has '.$_orderCnt.' orders';


Let me know if you have any query
Hello Friends

If you want to get admin path name then use my below code

echo (string)Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');

It will return admin or your admin custom path name

Let me know your comment if its not work for you
Hello Friends

Here, I will be showing you how you can read XML nodes from config.xml file of your module. It’s through the Magento way with Mage::getConfig()->getNode() function. :)
Here is the XML code of my config.xml file. I will be reading the nodes of this XML file.
<default>
    <catalog>
        <mypage>
            <name>myname</name>
            <age>100</age>
            <address_one>earth</address_one>
        </mypage>
    </catalog>
</default>


Here is the code to read the node of the above XML file. Here, ‘catalog/mypage‘ is parent nodes path. It depends upon XML node layout.
// prints 'myname'
echo Mage::getConfig()->getNode('catalog/mypage')->name;

// prints '100'
echo Mage::getConfig()->getNode('catalog/mypage')->age;

// prints 'earth'
echo Mage::getConfig()->getNode('catalog/mypage')->address_one;


Let me know your comment if its help you or not
Hello Friends

If you want to know about keyword like Global, Website, Store, Store View in magento then read my below article

 Global: This refers to the entire installation.
    Website: Websites are ‘parents’ of stores.  A website consists of one or more stores. Websites can be set up to share customer data, or not to share any data


    Store (or store view group): Stores are ‘children’ of websites.  Products and Categories are managed on the store level.  A root category is configured for each store view group, allowing multiple stores under the same website to have totally different catalog structures.


    Store View: A store needs one or more store views to be browse-able in the front-end.  The catalog structure per store view will always be the same, it simply allows for multiple presentations of the data in the front.  90% of implementations will likely use store views to allow customers to switch between 2 or more languages.
Hello Friends

IF you want to add external database connection or custom database connection or multiple database connection in magento then you can use below config.xml file from 


app>code>codepool>packagename>modulename>etc>config.xml

Add the following code  to your config.xml under global tag

Consider keyur_shah module

<global>

        <resources>

            <test_write>

                <connection>

                    <use>test_database</use>

                </connection>

            </test_write>

            <test_read>

                <connection>

                    <use>test_database</use>

                </connection>

            </test_read>

            <test_setup>

                <connection>

                    <use>core_setup</use>

                </connection>

            </test_setup>

            <test_database>

                <connection>

                    <host><![CDATA[localhost]]></host>

                    <username><![CDATA[db_username]]></username>

                    <password><![CDATA[db_password]]></password>

                    <dbname><![CDATA[db_name]]></dbname>

                    <model>mysql4</model>

                    <type>pdo_mysql</type>

                    <active>1</active>

                </connection>

            </test_database>

        </resources>

    </global>


Get data

    $resource   = Mage::getSingleton('core/resource');

    $conn       = $resource->getConnection('test_read');

    $results    = $conn->query('SELECT * FROM TableName');

    print_r($results)
Hello Friends

In Magento, there are two columns in sales_flat_order table.
These are state and status, They both are different. State is used by magento to tell if the order is new, processing, complete, holded, closed, canceled, etc.

while Statuses are the one that YOU would be defining at the backend in System -> Order Statuses. Magento displays order STATUSES and not STATES in the backend order detail page to let you know which status is assigned as per your mapping.

Remember, multiple statuses can be mapped with one state, while vice versa is not possible.

Also you may know more, reading file /app/code/core/Mage/Sales/etc/config.xml 
Hello Friends

If you want to change product image on mouse hover of more view image then you can use my below script

Step1. open file on location given below

app/design/frontend/default/default/template/catalog/product/view/media.phtml

Step2. Search the code in media.phtml file

<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">  
   <!--nested img tag stays the same-->  
</a> 

 Step 3. Replace searched code with code below.

    <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onmouseover="$('image').src = this.href; return false;">  
       <!--nested img tag stays the same-->  
    </a>  

Let me know if you have any query
Hello Friends

If you want to create customer programmatically magento then you can use my below script.

$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();


$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId; 
$customer->setStore($store);

$customer->firstname = "keyur";
$customer->lastname = "shah";
$customer->email = "keyurshah.it@gmail.com";
$customer->password_hash = md5("test123");
$customer->save();

Let me know if you have any query
Hello Friends

If you want to Removing duplicate product image in Magento then you can use my below script.While you importing product this problem occur.you can also use this script when you have duplicate more view images in magento.

First of you have to copy below code and save with anyfilename.php and put in root folder folder and run this file with yourbaseurl/filename.php


include('app/Mage.php');  
//Mage::App('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
error_reporting(E_ALL | E_STRICT);
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
ob_implicit_flush (1);

$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
$_products = Mage::getModel('catalog/product')->getCollection();
$i =0;
$total = count($_products);
$count = 0;
foreach($_products as $_prod)
{
    $_product = Mage::getModel('catalog/product')->load($_prod->getId());
    $_md5_values = array();
     
    //protected base image
    $base_image = $_product->getImage();
    if($base_image != 'no_selection')
    {
        $filepath =  Mage::getBaseDir('media') .'/catalog/product' . $base_image  ;
        if(file_exists($filepath))
            $_md5_values[] = md5(file_get_contents($filepath));
    }
             
     
    $i ++;
    echo "\r\n processing product $i of $total ";

    // Loop through product images
    $_images = $_product->getMediaGalleryImages();
    if($_images){
        foreach($_images as $_image){
            //protected base image
            if($_image->getFile() == $base_image)
                continue;
             
            $filepath =  Mage::getBaseDir('media') .'/catalog/product' . $_image->getFile()  ;
            if(file_exists($filepath))
                $md5 = md5(file_get_contents($filepath));
            else
                continue;
             

            if(in_array($md5, $_md5_values))
            {
                $mediaApi->remove($_product->getId(),  $_image->getFile());
                echo "\r\n removed duplicate image from ".$_product->getSku();
                $count++;
            } else {
                $_md5_values[] = $md5;
            }    

        }
    } 
     
}

Let me know if its work for your or not
Hello Friends

To remove the Estimate shipping and taxes block you have to follow step

In order to do this you can copy app/design/frontend/base/default/layout/checkout.xml
 into
app/design/frontend/default/grayscale/layout/ (you need to replace default/grayscale with the path to your theme files)
 and after that
 customizeapp/design/frontend/default/grayscale/layout/checkout.xml removing the following line there:

<block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>

Another, more correct way (as it will not override whole default layout, so will be more upgrade-friendly) would be to edit local.xml file in app/design/frontend/default/grayscale/layout/ and add the following content right above the closing </layout> at the bottom:

<checkout_cart_index>
        <reference name="content">
                <block name="checkout.cart">
                        <remove name="checkout.cart.shipping"/>
                </block>
            </reference>

</checkout_cart_index>

After that you need to refresh Layouts cache at System > Cache Management.

Let me know your comment if its work or not
Hello Friends

In Magento ( System > Configuration > Store Email Addresses) we have a section for storing various store email addresses used in various sections like Orders,Sales etc

If you want to Get Store Email Addresses then you use below code


I am writing here the script to get these values

<?php



//General Contact

echo $name = Mage::getStoreConfig('trans_email/ident_general/name'); //sender name

echo $email = Mage::getStoreConfig('trans_email/ident_general/email'); //sender email



//Sales Representative

echo $name = Mage::getStoreConfig('trans_email/ident_sales/name'); //sender name

echo $email = Mage::getStoreConfig('trans_email/ident_sales/email'); //sender email



//Customer Support

echo $name = Mage::getStoreConfig('trans_email/ident_support/name'); //sender name

echo $email = Mage::getStoreConfig('trans_email/ident_support/email'); //sender email



//Custom Email 1

echo $name = Mage::getStoreConfig('trans_email/ident_custom1/name'); //sender name

echo $email = Mage::getStoreConfig('trans_email/ident_custom1/email'); //sender email



//Custom Email 2

echo $name = Mage::getStoreConfig('trans_email/ident_custom2/name'); //sender name

echo $email = Mage::getStoreConfig('trans_email/ident_custom2/email'); //sender email



?>           

Let me know your comment
Hello Friends

To protect your Magento backend against hackers and brute-force attacks, we recommend that you change the default URL to the Magento Admin Panel. It is a quick way to add an extra layer of security to your site.

Follow these steps to change the admin URL/path.

Note: Do NOT use the web interface in the Magento Admin Panel to change the admin URL, as this is known to cause severe problems.

Step 1 – Change Path

First, open the local.xml configuration file in your favorite text editor, or use the Text Editor in the cPanel File Manager. The file is usually located in the app/etc/ directory under your Magento installation. Locate the following code segment:

<admin>
  <routers>
    <adminhtml>
      <args>
        <frontName><![CDATA[admin]]></frontName>
      </args>
    </adminhtml>
  </routers>
</admin>


Step 2 – Refresh Cache

Let me know your comment
Hello Friends

I am writing here an important code snippet for getting the database connection details used in Magento

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");
        $_host = $config->host;
        $_uname = $config->username;
        $_pass = $config->password;
        $_dbname = $config->dbname;
        echo $_host; ///likewise

Let me know your comment
Hello All,

I am writing here the code to get various base directory paths, which might be useful.

Assuming the directory is named ‘magento’ where your site is present and its the root directory of the filesystem.

echo Mage::getBaseDir('base');
magento 

echo Mage::getBaseDir('app');
magento/app

echo Mage::getBaseDir('code');
magento/app/code

echo Mage::getModel('core/config')->getOptions()->getCodeDir();
magento/app/code

echo Mage::getBaseDir('design');
magento/app/design

echo Mage::getBaseDir('etc');
magento/app/etc

echo Mage::getBaseDir('lib');
magento/lib

echo Mage::getBaseDir('locale');
magento/app/locale

echo Mage::getBaseDir('media');
magento/media

echo Mage::getBaseDir('skin');
magento/skin

echo Mage::getBaseDir('var');
magento/var

echo Mage::getBaseDir('tmp');
magento/var/tmp

echo Mage::getBaseDir('cache');
magento/var/cache

echo Mage::getBaseDir('log');
magento/var/log

echo Mage::getBaseDir('session');
magento/var/session

echo Mage::getBaseDir('upload');
magento/media/upload

echo Mage::getBaseDir('export');
magento/var/export
    

Let me know your comment