How to Get Current Customer ID using object Manager (customer session) in Magento2 - magento source24

How to Get Current Customer ID using object Manager (customer session) in Magento2 - magento source24


How to Get Current Customer ID using object Manager (customer session) in Magento2 - magento source24 


In this blog post im share code with you to How to Get Current Customer ID using object Manager (customer session) in Magento2 - 

👉 In this method i'm using customer Session using Instance objectManager with \Magento\Framework\App\ObjectManager::getInstance().

👉 After that  i'm using customer Session using Class Magento\Customer\Model\Session to get Customer ID.


$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 

$customerSession = $objectManager->get(\Magento\Customer\Model\Session::class); 

$customer = $customerSession->getCustomer();

$customerId = $customer->getCustomerId();





Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post