How To Get Customer Address Data By Address ID In Magento 2

How To Get Customer Address Data By Address ID In Magento 2

The post gives the solution to get customer address data by address in Magento 2.

The Magento 2 store owners may sometimes employ techniques such as restricting the shipping of fragile or heavy items in certain areas to optimize the profit.

Also, managing the shipping process can be easy with organizing the customer addresses.

However, to implement such a system needs to get customer address data. The below code is an easy programmatic way to get customer address information using address ID in Magento 2 store.

Customer address data is got by Address ID using AddressRepositoryInterface interface.

Method to Get Customer Address Data by Address ID in Magento 2:

Create GetCustomerAddress.php Class in app/code/Vendor/Extension/Model:

Now you can access getAddressData($addressId) function as per your requirement by extending GetCustomerAddress class

That’s all for customer address data.

Easy steps, however, doubts in the implementation are welcome in the Comments section below. I’d be glad to help you out.

Please share the solution with the Magento community via social media.

Thank you.

(based on 13 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply

(based on 5 Reviews)