Способ 1
По аналогии с Magento 1.x
/** @return bool */
function rm_customer_logged_in() {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Customer\Model\Session $session */
$session = $om->get('Magento\Customer\Model\Session');
return $session->isLoggedIn();
}
Способ 2
/** @return bool */
function rm_customer_logged_in_2() {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\App\Http\Context $context */
$context = $om->get('Magento\Framework\App\Http\Context');
return $context->getValue(Magento\Customer\Model\Context::CONTEXT_AUTH);
}