0

I am working on admin notification area where I want to show on message which is related to currently logged-in user. I have created a column in db with user_id where after some functionally I push message with specific userID. now I want that when that specific user logged in he see all messages where

userId == currentLoggedInUserID

adminhtml_notification_block.xml this is the layout file where the collection file is placed. Now, when I create my custom collection file and extend the protected function

_initSelect()

protected function _initSelect()
    {
        $currentUserId =  $this->adminSession->getUser()->getId();
        parent::_initSelect();
        $this->addFieldToFilter('brand_user', $currentUserId);
        $this->addRemoveFilter();
        return $this;

it throws a NULL error because I can not get the session of the admin user in the collection file. what is the suggestion for this, please?

1 Answer 1

0

You can open the Observer folder, it has one function.

if ($this->_backendAuthSession->isLoggedIn()) {
            $feedModel = $this->_feedFactory->create();
            /* @var $feedModel \Magento\AdminNotification\Model\Feed */
            $feedModel->checkUpdate();
        }

In isLoggedIn, you will see the code for getting the current user's id. You can use this in your collection.

The code you provided is not complete, no one know what your adminSession is so next time try to provide the needed information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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