Thursday, July 21, 2016

How to get IPAddress in Magento 2

Here is a simple way to get IP Address in Magento 2
protected function getIpAddress()
    {
        $om = \Magento\Framework\App\ObjectManager::getInstance();
        $obj = $om->get('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress');
        $ip =  $obj->getRemoteAddress();
        return $ip;
    }
 
Link: https://www.polacin.com/magento2/how-to-get-ip-address-in-magento-2/ 

No comments:

Post a Comment

OAB (Oman Arab Bank) iPAY Internet Payment Gateway - Magento 2

  Magento 2 OAB iPAY Internet Payment Gateway   is an online payment solution that can be integrated with the Magento 2 eCommerce store. The...