What would be the Mage::getSingleton('customer/session')->getCustomer() in Magento 2?

Magento\Customer\Model\Session

is used in magento 2 to get object of Customer Session.

You can define in __construct() of php file,

public function __construct(
        \Magento\Customer\Model\Session $customerSession
    ) {
        $this->_customerSession = $customerSession;
    }

Now you can get the info using:

$customer = $this->_customerSession->getCustomer();

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$currentCustomer = $objectManager->get('Magento\Customer\Model\Session')->getCustomer();

Note: I am against of direct loading object with $objectManager, for better impact you can inject it in your constructor. I have just given example how you can achieve it. `

Better way


protected $_customerSession;

public function __construct(
\Magento\Customer\Model\Session $_customerSession 
) {
    $this->_customerSession=$_customerSession
}

Now you can easily get customer by simply

$this->_customerSession->getCustomer();