Skip to main content
deleted 1 character in body
Source Link
Ramesh
  • 986
  • 1
  • 14
  • 40

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

events.xml

<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="Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver"instance="MyNameSpace\MyModuleName\Observer\PredispatchAdminActionControllerObserver" />
</event>

NameSpace/ModuleName/Model/Feed.php

<?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->addWriter($writer);
    $logger->info('Your text message');
    $this->logger->debug($message);
  }

}

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

events.xml

<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="Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver" />
</event>

NameSpace/ModuleName/Model/Feed.php

<?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->addWriter($writer);
    $logger->info('Your text message');
    $this->logger->debug($message);
  }

}

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

events.xml

<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" />
</event>

NameSpace/ModuleName/Model/Feed.php

<?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->addWriter($writer);
    $logger->info('Your text message');
    $this->logger->debug($message);
  }

}

edited tags
Link
Source Link
Ramesh
  • 986
  • 1
  • 14
  • 40

Magento 2 custom notifications

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

events.xml

<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="Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver" />
</event>

NameSpace/ModuleName/Model/Feed.php

<?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->addWriter($writer);
    $logger->info('Your text message');
    $this->logger->debug($message);
  }

}