0

Fetch customer details using query or object manager

Want to display the following fields

First Name Last Name Email telephone State /region pincode

1
  • You can try this code. If you have any issue then you can tell me :) Nov 24, 2017 at 6:07

1 Answer 1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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