0

Fetch customer details using query or object manager

Want to display the following fields

First Name Last Name Email telephone State /region pincode

  • You can try this code. If you have any issue then you can tell me :) – Rohan Hapani Nov 24 '17 at 6:07
1
$customerId = 3;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerObj = $objectManager->create('Magento\Customer\Model\Customer')->load($customerId);
$customerAddress = array();

//Get all customer Data
var_dump($customerObj->getData());

foreach ($customerObj->getAddresses() as $address)
{
    $customerAddress[] = $address->toArray();
}

//Here you will get Customer Address data like region, city etc.
foreach ($customerAddress as $customerAddres) {

    echo $customerAddres['street'];
    echo $customerAddres['city'];
}

Thanks

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.