am trying to insert custom notifications into adminnotification_inbox table as per core module Magento-AdminNotifications approache but am't able to insert custom notifications. Code is in below


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch">
    <observer name="adminnotification" instance="MyNameSpace\MyModuleName\Observer\PredispatchAdminActionControllerObserver" />


<?php namespace  ConversionBug\Core\Model;             

Class Feed extends \Magento\AdminNotification\Model\Feed{

  public function __construct(\Psr\Log\LoggerInterface $logger, 
                              \Magento\Framework\Stdlib\DateTime\DateTime $date) {
    $this->_logger = $logger;        
    $this->date = $date;

  public function checkUpdate() {
    $this->_logger->debug("Feed Message here");
    $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
    $logger = new \Zend\Log\Logger();
    $logger->info('Your text message');


  • Your code only shows attempts to log message. What did you try to insert notifications ? – Raphael at Digital Pianism Aug 20 '16 at 9:37

First you need to inject Magento/AdminNotification/Model/InboxFactory in your constructor:

protected $_inboxFactory;

public function __construct(\Psr\Log\LoggerInterface $logger, 
                              \Magento\Framework\Stdlib\DateTime\DateTime $date,
                              \Magento\AdminNotification\Model\InboxFactory $inboxFactory) {
    $this->_logger = $logger;        
    $this->date = $date;
    $this->_inboxFactory = $inboxFactory;

Then you will need to have data stored in an array like this:

$data = [
    'severity' => $severity,
    'date_added' => $itemPublicationDate,
    'title' => $title,
    'description' => $description,
    'url' => $link

Finally you can insert your admin notification in the database by calling:


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.