How to open native map app from the mobile browser

Friday, March 7, 2014
If we need in our mobile web application a link to open google map app of mobile phone to view an address, then, we can make use of html hyperlink tag for it. But,the method of opening google mag app in different devices are different. For iphone/iOS, android phones,windows phones,blackberry, all have different code to call map app from mobile browser.
For example we want to find location "New Delhi",
For Desktop:
<a href="">Find Us</a>

For iPhone:
An iPhone would actually hijack this URL and open the map app automatically.
But it would not plot the route. To plot the route we'd need to modify the URL to:
<a href=" New%20Delhi">Find Us</a>

Here we are setting the source address to "Current Location" and the destination address to our store. If you'd like more information about constructing query strings for Google Maps take a look at In my experience anything you can do with them on Google Maps will work in the iPhone app.
For Android:
Instead of simply hijacking URLs to Google Maps like the iPhone, Android is employing the geo: protocol which relates the specific intent to find a geographic location. For information on the geo: protocol and other 'intents' take a look at the following link.
Here is how we'll construct our URL for Android.
<a href="geo:New%20Delhi">Find Us</a>

How to Get Store ID in Magento

Thursday, December 6, 2012
Many times during coding we require the store ID of the magento store, We can get this by using the below code in magento :

Install Magento in Ubuntu

To install magento in Ubuntu, first Open the terminal to run the commands.
Navigate to the directory (Inside www folder) where you need to install Magento.
$ cd /var/www 
Download magento files by using the following command:
$ wget
After the downloading process completes, just decompress the downloaded file:
$ tar -zxvf magento-
Now you can find a new folder “magento”. Just get into it.
$cd magento
Then set permissions for some folders like media, var and app/etc to 777:
$ chmod -R 777 media var
$ chmod 777 app/etc

Get All Items & Totals In Magento Shopping Cart

Wednesday, October 31, 2012
This blog will show you how to get all items in a shopping cart and totals in a magento store :
 $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
 foreach($items as $item) {
    echo 'Product ID: '.$item->getProductId();
    echo 'Product Name: '.$item->getName();
    echo 'Product Sku: '.$item->getSku();
    echo 'Product Quantity: '.$item->getQty();
    echo 'Product Price: '.$item->getPrice();

Price Currency Conversion in Magento

This article is to show you how to convert price amount from one currency of the shop to another currency.
// Currency conversion rates have to be available in the target currency
$fromCur = ‘USD’; // currency code to convert from – usually your base currency
$toCur = ‘EUR’; // currency to convert to
$price = Mage::helper(‘directory’)->
currencyConvert(1000, $fromCur, $toCur);
// if you want it rounded:
$converted_final_price = Mage::app()->getStore()->roundPrice($price);

How to show Category List in Magento

You can show all categories present in magento.
There are different methods to get the category list. Below are some possible methods:-
Get all categories
The following code will fetch all categories (both active and inactive) that are present in your Magento Shop.
$categories = Mage::getModel('catalog/category')

Get all active categories:

Emulation process in Magento

Thursday, September 27, 2012
Recently,I had a task to send an custom transactional e-mail from admin panel on some event.And the email template was same as used in the frontend store. So, I was trying to make use of the same block and phtml of frontend theme to call in that email. But,i found that that,we cannot call frontend phtml files in the emails sending from admin.
There is a concept of emulation in magento which allow us to do the same.By using this method we can make use of frontend template files to call in mails sending from Admin.
This feature is available in magento 1.5 & above version.By using Emulation model a.k.a. Mage_Core_Model_App_Emulation class , we can emulate stores in magento.
Code to be used:
$appEmulation = Mage::getSingleton('core/app_emulation');
//Start environment emulation of the specified store
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
 * Any code thrown here will be executed as we are currently running that store
 * with applied locale, design and similar
//Stop environment emulation and restore original store
You will need something similar also,when you want to send custom transactional e-mail for all stores at the same time as cronjob. However, the problem is that e-mail had {{block}} inside and block template needed to respect different theme set for each store.