Magento2 How To Add Multiple System Notification Using Single File

by Sanjay Shiyal   Last Updated October 19, 2019 11:09 AM - source

I have use below code to add admin system notification and it is working fine but it add's only single notification , and i want to add multiple notification's using single file

enter image description here

does anyone know how can i do that ?

app\code\Vendor\Module\etc\di.xml

<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\Notification\MessageList">
        <arguments>
            <argument name="messages" xsi:type="array">
                <item name="custom_message" xsi:type="string">Vendor\Module\Model\Admin\Quote\Messages</item>
            </argument>
        </arguments>
    </type>
</config>

app\code\Vendor\Module\Model\Admin\Quote\Messages.php

<?php

namespace Vendor\Module\Model\Admin\Quote;

use Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection;
use Magento\Backend\Model\UrlInterface;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\Notification\MessageInterface;

class Messages implements MessageInterface
{

    protected $backendUrl;
    private $adminSessionInfoCollection;
    protected $authSession;

    public function __construct(
        Collection $adminSessionInfoCollection,
        UrlInterface $backendUrl,
        Session $authSession
    ) {
        $this->authSession = $authSession;
        $this->backendUrl = $backendUrl;
        $this->adminSessionInfoCollection = $adminSessionInfoCollection;
    }

    public function getText()
    {
        $message = __('Test Message 1 ');
        return $message;
    }
    public function getIdentity()
    {
        return md5('Test Message 1 ' . $this->authSession->getUser()->getLogdate());
    }
    public function isDisplayed()
    {
        return true;
    }
    public function getSeverity()
    {
      \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL;
    }
}


Related Questions


System Config page at backend is showing Blank page

Updated March 24, 2017 07:09 AM


Change admin backend password minimum length

Updated June 26, 2019 04:09 AM

Magento 2 add admin config setting on the fly

Updated February 01, 2018 10:09 AM