How to get distance between two places using Google Maps

logo_php

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 = “http://maps.googleapis.com/maps/api/directions/json?origin=”.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);
curl_close($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

Magento-Logo

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



static-block-identifier

In case if reference already there then just use

static-block-identifier

Enjoy 🙂

magento check for home page

magento-logo

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.

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

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

magento-logo

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): ?>
    <ul>
        <?php foreach($_categories as $_category): ?>
            <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo $_category->getName() ?>
                </a>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                    <ul>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

Install Komodo Edit 8 in Ubuntu 14.04

komodo-edit

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

directory-is-not-writable-error

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.