Search code examples
modelmagento2

What would the magento 2 equivalent of Mage::getModel('customer/customer')->loadByEmail(); be?


What is the equivalent of this code in magento 2?

Mage::getModel('customer/customer')->loadByEmail(); 

Solution

  • Please use this code:

    <?php 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $customer =  $objectManager->get('Magento\Customer\Model\Customer');
    $customer->setWebsiteId('1');
    $customer->loadByEmail('[email protected]'); 
    ?>