Magento is an e-commerce platform capable of expanding core functions. One of the very useful functions is administrator notification. Magento uses this function in the backend to notify administrators of updates, upgrades, notification patches or bugs that need to be fixed to improve the user experience. Today, this blog will show you how to create custom Admin System Messages and Admin Notification Messages.

A. Add Custom Admin System Message in Magento 2

Step 1: di.xml

We start by adding a new item into the message list, which will point to the corresponding model class. It can be done via the Dependency Injection.

Add the following “type” node into “app/code/Magenest/Notification/etc/adminhtml/di.xml”, a file of your module as shown below.

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Magento\Framework\Notification\MessageList">
           <argument name="messages" xsi:type="array">
               <item name="Notification" xsi:type="string">Magenest\Notification\Model\Message\Notification</item>

Step 2: Notification.php

Now we will create a Message Model Class itself, this class must implement the "\Magento\Framework\Notification\MessageInterface" interface.

Create app/code/Magenest/Notification/Model/Message folder. In this folder, create a Notification.php file with the following content:

namespace Magenest\Notification\Model\Message;
class Notification implements \Magento\Framework\Notification\MessageInterface
   public function getIdentity()
       // Retrieve unique message identity
       return 'identity';
   public function isDisplayed()
       // Return true to show your message, false to hide it
       return true;
   public function getText()
       // message text

       return "Notification Add Successfully";
   public function getSeverity()
       // Possible values: 
       return self::SEVERITY_CRITICAL;

You can see that there are four message types available. And each one is defined as a constant value:


Clear cache of your Magento installation, login into the Admin page and you will see the result as shown below

Admin notification in Magento 2: Add Custom Admin System Message in Magento 2

B. Add Admin Notification Messages in Magento 2

And now we will cover another type of notifications that uses Default Admin NotifierNotifications.

We can add new admin notification using “Magento\Framework\Notification\NotifierInterface”.

protected $notifierPool;

   public function __construct(
       \Magento\Framework\Notification\NotifierInterface $notifierPool
   ) {
       $this->notifierPool = $notifierPool;

   public function addNotification()
       // link to detail notification page
       $NotificationUrl = $this->getUrl('adminhtml/');

       // Add notice
           'Wellcome to Magenest',
           'Message description text.',

       // Add minor severity message
           'Message 1',
           'Message description text.',

       // Add major severity message
           'Message 2',
           'Message description text.',
       // Add critical severity message
           'Wellcome to Magenest',
           'Message description text.',

In the code above, four messages have been added using functions: addNotice, add Minor, addMajor, addCritical.

Clean the cache and go to the URL /magenest/notification/index in the browser, and go back to the dashboard, you will see the result as shown below:

Admin notification in Magento 2: Add Admin Notification Messages in Magento 2

And now, you can now log out and re-login into the admin page, You will see a message pop up as shown below:

Admin notification in Magento 2: Add Admin Notification Messages in Magento 2 - Popup

Thanks for reading! Follow our blog to read more useful Magento 2 guidelines.