Thursday, 22 September 2016

How to get customer data from email id in magento 2

$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$customer_email=$_REQUEST['list'];
///echo $customer_email;exit;

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


    $url = \Magento\Framework\App\ObjectManager::getInstance();
    $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');
    $state = $objectManager->get('\Magento\Framework\App\State');
    $state->setAreaCode('frontend');
    $websiteId = $storeManager->getWebsite()->getWebsiteId();
    // Get Store ID
    $store = $storeManager->getStore();
    $storeId = $store->getStoreId();
    $customerFactory = $objectManager->get('\Magento\Customer\Model\CustomerFactory');
    $customer=$customerFactory->create();
    $customer->setWebsiteId($websiteId);
    $customer->loadByEmail($customer_email);// load customer by email address
    //echo $customer->getEntityId();
    //$customer->load('1');// load customer by email address
    $data= $customer->getData();
$customer_id=$data['entity_id'];

5 comments: