How to Get Logged in Customer Data in Magento 2

How to Get Logged in Customer Data in Magento 2

Knowing your potential buyers is the key to selling them effectively. Collecting the data of logged in customers provides you the important details to know who your customers are, what they want, and how to serve them better. Magento 2 store admin may want to implement certain features based on customer attributes of logged in users. For example, only logged in customers are allowed to view the price details. Admin may want to offer shipping services to particular customer groups only.

Customer attributes like age, location, gender can be handy for marketing insights. For example, you can target young customers as per their taste. Women may obviously not want to get suggestions for men’s trousers!

Admin needs to retrieve customer attributes value for such features. To get logged in customer data in Magento 2, one needs to follow one of the below methods.

Methods to get logged in customer data in Magento 2:

  1. using Object Manager
  2.  using Block class

Follow the above method and implement flawless features based on customer attributes!

Doubts regarding the topic are welcome in the comments section below and I’d be happy to help. ?

Flash 5 stars if the post has helped you to offer amazing features for your privileged customers ?

Happy Coding! ?

(based on 11 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply