How to get distance between two places using Google Maps

Are you looking for getting distance between two places using google map, just use the below php code for action.

Use curl to use google map api to get the distance.
Here the format of address
$address = $value[“street”].” “.$value[“region”].” “.$value[“country_id”].” “.$value[“zip_code”];

Now just paste the code

$url = “”.str_replace(‘ ‘, ‘+’, $source_address).”&destination=”.str_replace(‘ ‘, ‘+’, $destination_address).”&sensor=false”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
$response_all = json_decode($response);
// print_r($response);
$distance = $response_all->routes[0]->legs[0]->distance->text;

How to Call Static Block from CMS Pages in Magento

I have come to many situation to call static block from CMS Pages, and i am using the below code to do this trick. You can use this code to call a static block on any of your CMS page like homepage so you just follow the steps
Go To CMS->Pages
Select Your page

Go To Design->Layout Update XML
Reference means the block will call on left right or Content


In case if reference already there then just use


Enjoy 🙂

magento check for home page

Here is the tip for you to check for homepage in Magento. I had come across a situation to add a banner block conditionally on the homepage. The below code helps me to accomplish the same. Hope this will help you too.

Mage::getSingleton('cms/page')->getIdentifier() == 'home'  &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' 
) :

How to display a menu with categories, sub-categories in Magento

If you need to display a custom menu based on your categories, subcategories in magento, you can use the below code for the same.

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
        <?php foreach($_categories as $_category): ?>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo $_category->getName() ?>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                        <?php foreach($_subcategories as $_subcategory): ?>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                        <?php endforeach; ?>
                <?php endif; ?>
        <?php endforeach; ?>
<?php endif; ?>

Install Komodo Edit 8 in Ubuntu 14.04

This article gives you support on how to install Komodo Edit in Ubuntu 14.04. Komodo Edit offers support for all your major languages,including Python, PHP, Ruby, Perl, HTML, CSS ,JavaScript etc.

The installation is simple, you can done it with the following three commands from the terminal.(Press Ctrl+Alt+T to open the terminal)

sudo add-apt-repository ppa:mystic-mirage/komodo-edit

sudo apt-get update

sudo apt-get install komodo-edit

‘The directory is not writable by server’ error in Magento

If you are facing an error ‘The directory is not writable by server’ in magento please ensure the following :

First of all Check if the server has the write permission on var and media folders. This might solve the issue. If still the issue persists go through the following steps:

check whether the ‘media/catalog’, ‘media/wysiwyg’ and ‘media/images’ are there in the media folder. If it doesn’t exists create the folders, and give write permisission for those folders.

Hope this will resolve your issue.