2017 © Pedro Peláez
 

magento-module geoip

Connects MaxMind GeoIP DB to Magento

image

tim-bezhashvyly/geoip

Connects MaxMind GeoIP DB to Magento

  • Monday, November 2, 2015
  • by razbakov
  • Repository
  • 83 Watchers
  • 83 Stars
  • 18 Installations
  • C
  • 1 Dependents
  • 0 Suggesters
  • 23 Forks
  • 6 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

Overview

This extension allows you to use free GeoIP Lite database by MaxMind with your Magento installation., (*1)

Installation

Just copy all files to your Magento installation respecting directory structure. Make sure your var directory is writable by web-server user (by default it should be). If you want GeoIP database to be updated automatically make sure your Magento cron-job is set up and running. Logging out and in is not required., (*2)

Configuration

After installation a new field will be added to System\Configuration\General\General\Countries Options group indicating the date of last database update and the button to force synchronization. Note that frequent synchronizations will result you being banned at MaxMind server for several hours. MaxMind GeoIP Lite database is updated on first Thursday of the month so if you have have Magento cron-job running you will not need to force synchronization anymore but on the first run., (*3)

Usage

This extension only adds MaxMind GeoIP Lite database to your Magento installation and maintains its updates. It doesn't do anything else out of the box (yet). However if comes with a set of methods you can implement in your template or extension., (*4)

$geoIP = Mage::getSingleton('geoip/country');

/**
 * Returns you the ISO 3166-1 code of visitors country.
 */
echo $geoIP->getCountry();

/**
 * Returns true or false depending if current visitors country is among allowed countries.
 * If there are no allowed countries in the system returns true.
 */
if ($geoIP->isCountryAllowed()) {
    // ...
}

/**
 * Adds country (or array of countries) to list of allowed countries.
 */
$geoIP->addAllowedCountry('DE');
$geoIP->addAllowedCountry(array(
    'US',
    'CA'
));

/**
 * Or just get a country code of a specific IP
 */
echo $geoIP->getCountryByIp('94.230.212.77');

Please note that geoip/country is initialized at each Magento load. In order to save system resources please always use it as a singleton., (*5)

The list of allowed countries is initially populated from System\Configuration\General\General\Countries Options\Alowed Countries multi-select field of your Magento configuration. The addAllowedCountry method is not adding country to system configuration but adds it to internal list extension uses for isCountryAllowed method., (*6)

Global Restrict

To globally restrict access to your site by IP consider extending the controller_front_init_before event in your own module and add dependancy to geoip, (*7)

Credits

Thanks a lot to MaxMind for providing a free database. Additionally this extension partly uses the code from MaxMind GeoIP PHP API., (*8)

The Versions

02/11 2015

dev-master

9999999-dev https://github.com/tim-bezhashvyly/geoip

Connects MaxMind GeoIP DB to Magento

  Sources   Download

OSL-3.0

The Requires

 

by Tim Bezhashvyly

18/09 2014

0.2.0

0.2.0.0 https://github.com/tim-bezhashvyly/geoip

Connects MaxMind GeoIP DB to Magento

  Sources   Download

OSL-3.0

The Requires

 

by Tim Bezhashvyly

12/12 2013

0.1.2

0.1.2.0 https://github.com/openstream/geoip

Connects MaxMind GeoIP DB to Magento

  Sources   Download

OSL-3.0

The Requires

 

by Tim Bezhashvyly