I have the following code that retrieve the data from a customer by its email:
<?php
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
use Magento\Framework\App\Request\Http as RequestHttp;
use Magento\Framework\App\Response\Http as ResponseHttp;
use Magento\Framework\Event;
use Magento\Framework\Filesystem;
use Magento\Framework\App\AreaList;
use Magento\Framework\App\State;
class CustomerApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface {
/**
* @var \Magento\Customer\Model\ResourceModel\CustomerRepository
*/
protected $_customerRepository;
/**
* @var \Magento\Customer\Api\Data\CustomerInterface
*/
protected $_customerInterface;
protected $_customInterface;
public function launch() {
$response = $this->getCustomer();
//return $response;
return $this->_response;
}
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
{
return false;
}
protected $customer_Repository;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param Event\Manager $eventManager
* @param AreaList $areaList
* @param RequestHttp $request
* @param ResponseHttp $response
* @param ConfigLoaderInterface $configLoader
* @param State $state
* @param Filesystem $filesystem
* @param \Magento\Framework\Registry $registry,
\Magento\Customer\Model\ResourceModel\CustomerRepository $customer_Repository,
\Magento\Customer\Api\Data\CustomerInterface $customerInterface
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
Event\Manager $eventManager,
AreaList $areaList,
RequestHttp $request,
ResponseHttp $response,
ConfigLoaderInterface $configLoader,
State $state,
Filesystem $filesystem,
\Magento\Framework\Registry $registry,
\Magento\Customer\Model\ResourceModel\CustomerRepository $customer_Repository,
\Magento\Customer\Api\Data\CustomerInterface $customerInterface
) {
$this->_objectManager = $objectManager;
$this->_eventManager = $eventManager;
$this->_areaList = $areaList;
$this->_request = $request;
$this->_response = $response;
$this->_configLoader = $configLoader;
$this->_state = $state;
$this->_filesystem = $filesystem;
$this->registry = $registry;
$this->customer_Repository = $customer_Repository;
$this->_customerInterface = $customerInterface;
}
public function getCustomer() {
$data = $this->customer_Repository->get("[email protected]");
return $data;
}
}
The variable $data
received get a Magento\Customer\Model\Data\Customer
Object and do not know who to check if the customer exist.