0

customer_list.phtml

$om = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $om->create('Magento\Customer\Model\ResourceModel\Online\Grid\Collection');
$customerData = $customerSession->getData();
echo "<pre/>";
print_r($customerData);
exit;

Result

enter image description here

Expected result

I want to show registered online customer only.

  • 1
    In your collection, You can add filter like email id is not empty. so you will get only registered customer – Pawan Apr 8 at 8:50
  • 1
    in my case above code is returning only registered customer only! – Pawan Apr 8 at 9:11
  • 1
    Yes it will keep for time which is defined in config – Pawan Apr 8 at 9:42
  • 1
    When I log out , above collection get empty.. – Pawan Apr 8 at 10:10
  • 1
    great, I added my comment as answer, so you can accept it :) – Pawan Apr 8 at 11:35
2

In your collection, You can add filter like email id Or Customer Id is not empty. So it will give you only registered customer.

When Customer log out , Collection will remove that customer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.