Get Customer Address data by address id in Magento 2.

You can get the customer address data by Address id using AddressRepositoryInterface interface.

Magento\Customer\Api\AddressRepositoryInterface contains the getById($addressId) function with pass first argument as address id to fetch specific customer address data.

You can get the address data by above function with passing address id as first arguments.

$addressId = 10;
$address = $this->getAddressData($addressId);
echo $address->getId();
echo $address->getCustomerId();

Leave a Reply