I have a telephone number which is given in Default address..by using this telephone number i need to get Customer Full data.Data like customer id, customer full name..etc

  • 1
    Address Phone number ? or you created new customer attribute ? – Pankaj Pareek Jul 7 '17 at 11:04
  • Welcome to SE. Try to explain your issue in details also if you have tried any code put in here. It will be much easy to help you. – Priyank Jul 7 '17 at 11:11
  • It is default Billing Address -> Phone number. – user3374995 Jul 7 '17 at 12:25
  • Please check the below code and get back with u r feedback thanks – Nagaraju K Jul 7 '17 at 12:34
  • Please let me know whether it's working or not. thanks – Nagaraju K Jul 7 '17 at 12:35

Let us $telephone_number is value of current customer's telephone number than you can use $customer and get your data like as:-

| improve this answer | |

As you have a rest tag , I assume you want to get it via REST API.

You can construct a GET request to <yoursite.com>/rest/<store_code>/V1/customers/search with the following parameters:

searchCriteria[filterGroups][0][filters][0][field]: addresses[telephone]

searchCriteria[filterGroups][0][filters][0][value] : 123456789

searchCriteria[filterGroups][0][filters][0][conditionType]: eq

Of course, you've to add admin token on header or you'll likely to get permission denied error.


| improve this answer | |

Please use the below code in test.php and run the same in the root folder.


use \Magento\Framework\App\Bootstrap; 
    $bootstrap = Bootstrap::create(BP, $_SERVER);
    $objectManager = $bootstrap->getObjectManager();
    $url = \Magento\Framework\App\ObjectManager::getInstance();
    $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');
    $state = $objectManager->get('\Magento\Framework\App\State'); 
    $websiteId = $storeManager->getWebsite()->getWebsiteId();
    // Get Store ID
    $store = $storeManager->getStore();
    $storeId = $store->getStoreId();
    $customerFactory = $objectManager->get('\Magento\Customer\Model\CustomerFactory'); 
    //$customer->loadByEmail('roni_cost@example.com');// load customer by email address
    //echo $customer->getEntityId();
    // $customer->load('1');// load customer by using ID
    //$data= $customer->getData();

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager
    $resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
    $connection = $resource->getConnection();
    $tableName = $resource->getTableName('customer_address_entity');    
    $sql = "SELECT entity_id FROM `customer_address_entity` WHERE `telephone`='987456123' ";
    $result = $connection->fetchAll($sql);
    foreach($result as $key => $value)
        $myCustomerId = $value['entity_id'];
    echo "<pre>";
    $data= $customer->getData();

   echo 'Lastname=='.$data['lastname']."</br>";
   echo 'DOB=='.$data['dob'];


Screenshot: http://prntscr.com/fss6ql

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.