Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
OR
if you are getting “503 Service Temporarily Unavailable error"?

Go to root folder of the project and find maintenance.flag file and delete it.
Than, Go to var/ folder and delete cache folder.

Now refresh you're page . hope fully you're problem has been solved.


Guys If you want to set you're maintenance page or other information regarding this visit..
http://www.magentocommerce.com/knowledge-base/entry/configuration-general-maintenance-mode

Magento show admin path hint.

// For enable admin template path hint.
INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1);

// For enable admin template block path hint.
INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES('default', 0, 'dev/debug/template_hints_blocks', 1);


// For disable admin template path hint

UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'

// For disable admin template block path hint

UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints_blocks'

Magento get Product, Shipping, Billing and customer info using order Id.

$orderId = '10000015';
$order = Mage::getModel('sales/order')->load($orderId);
// For getting Customer Order Info
$order->getCustomerId(); // get customer Id
$order->getCustomerEmail(); // get customer email

 print_r($order->getData()); //show all order data


// For getting Product Order Info
$items = $order->getAllItems();
      foreach ($items as $itemId => $item){
$item->getName(); // get order product name
print_r$item->getData()); //show all order product data

}

// For getting Shipping Order Info
  $shippingId = $order->getShippingAddress()->getId();
       $shipAddress = Mage::getModel('sales/order_address')->load($shippingId);
        print_r($shipAddress->getData());
If you want Billing/Shipping Country name see here
   
// For getting Billing Order Info

     $billingId = $order->getBillingAddress()->getId();
     $billAddress = Mage::getModel('sales/order_address')->load($billingId);
      print_r($billAddress->getData());



Create a custom Database connection in magento

Create a connect.php file in root folder. and past the below code . now you are able to access Data base on this file.

require_once ("app/Mage.php");
$app = Mage::app('default');

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");

$dbinfo = array("host" => $config->host,
            "user" => $config->username,
            "pass" => $config->password,
            "dbname" => $config->dbname
);

$hostname = $dbinfo["host"];
$user = $dbinfo["user"];
$password = $dbinfo["pass"];
$dbname = $dbinfo["dbname"];
$con = mysql_select_db($dbname,mysql_connect($hostname,$user,$password)) ;

create log file in magento?

Put any message on log file ..
Go to Admin > System > Configuration > Developer > Log Settings
Change the value to YES for Enabled field.

Mage::log("Write you're message here. those you want to write on log file");
This message will be display on log file(root folder/var/log/system.log)

if you want to create you're own log file ...
Mage::log("Write you're message here. those you want to write on log file or any variable", null, 'filename.log', true);
Here 4th param means force logging
You're custom file will be create on var/log/filename.log


NOTE:- For Log file 2 things required..
1) Developer mode must be set to true
2) Logging must be activated in the system configuration.

you can find log method on app/Mage.php file in line Number 784.

public static function log($message, $level = null, $file = '', $forceLog = false){}

how to change admin url in magento?

Step1:- Go To root folder than
app/etc/local.xml 
open local.xml file and change below "CDATA[admin]" code.

 <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
NOTE:- use only small character.

Step2:- go to var/ folder and delete cache folder.  Now open admin with you're new admin name url..

Magento Static, CMS, BASE, SKIN, JS, MEDIA , Current and any kind of URL

Get Base Url
<?php echo Mage::getBaseUrl(); //output=> http://yourwebsitename.com/ ?>

Get Media Base Url
 <?php echo Mage::getBaseUrl('media');  //output=> http://yourwebsitename.com/media/  ?>

Get Js Base Url
  <?php echo Mage::getBaseUrl('js');  //output=> http://yourwebsitename.com/js/ ?>

Get Skin Base Url
  <?php echo Mage::getBaseUrl('skin');  //output=> http://yourwebsitename.com/skin/ ?>


For CMS and Static block url use 

Get Skin Url
  <?php {{skin url='images/imagename.jpg'}}  ?>

Get Media Url
  <?php {{media url='/sampleimage.jpg'}}  ?>

Get Store Url
  <?php {{store url='.html'}}  ?>

Get Current Url
 <?php echo  Mage::helper('core/url')->getCurrentUrl(); ?>


Get Magento Directory

<?php echo Mage::getBaseDir(); //output : /var/www/html/magento  ?>
<?php echo Mage::getBaseDir('app'); //output : /var/www/html/magento/app  ?>
<?php echo Mage::getBaseDir('media');  //output : /var/www/html/magento/media  ?>

Same way you can find  code, lib, etc  directory path ....

Magento email to friend without login

Mostly, Magento Email To A Friend or Send To A Friend on the product details page. user does not send an email to you're friend until . he/she does not logged in.
If you want to send an email to you're friend without loggin. Please follow below step.

Login Backend >> System > Configuration > Email to a Friend 
set Allow for Guests = Yes

Now Refresh cache  Go To >> System >> Cache Management and than see you're product page.

How to call phtml file in cms page in magento?


Go to Admin >> CMS >> Pages  click on it. Now Edit or Add New page go to content tab paste the below code and save

{{block type="core/template" name="a-name" template="cms/yourefilename.phtml"}}

inside template="" you can write your file path. and in name="" you can give proper and unique name , in type="" you can write your module directory .

If you want to call through XML Go to Design tab and paste below code . 


<reference name="content">
<block type="core/template" name="unique-name" template="cms/yourefilename.phtml"/>

</reference>

Magento call static block in .phtml file.

First you need to create a static block in admin section.
Go to Admin >> CMS >> Static Blocks  . After create static block use identifier block name

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('you're_identifier_block_name')->toHTML(); ?>


If you want to call static block through XML file.

<reference name="right">  
        <block type="cms/block" name="block_name" as="block_name">  
           <action method="setBlockId"><block_id>you're_identifier_block_name</block_id></action>  
        </block>  
</reference>

Format price in the current locale and currency

Please change $finalPrice to you're price variable  ....

<?php  echo  $formattedPrice = Mage::helper('core')->currency($finalPrice, true, false); ?>

                                         OR
<?php  echo $formattedPrice = Mage::helper('core')->currency($finalPrice,true,false); ?>