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();