🔔 Magento 2 Admin Notifications – Show Custom Alerts in Backend
Want to notify the admin about a module update, important alert, or system issue? Magento 2 allows you to create custom backend notifications using the admin notification inbox.
🎯 What You’ll Learn
We’ll create a simple script that pushes a custom notification into the Magento 2 admin panel (like the ones you see at the top of the dashboard).
📦 Step 1: Create the Notification via Script
You can add a notification from anywhere in your module (e.g., Observer, CLI command, setup script, etc.). Here’s a standalone example in a script.
use Magento\AdminNotification\Model\Inbox; /** @var \Magento\Framework\App\Bootstrap $bootstrap */ require __DIR__ . '/app/bootstrap.php'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); $obj = $bootstrap->getObjectManager(); /** @var Inbox $inbox */ $inbox = $obj->create(Inbox::class); $inbox->addCritical( 'Important Update', 'A new version of Vendor_Module is available. Please update soon!', 'https://example.com/update-info' // link for details (optional) );
🛠️ Available Message Types
You can choose different types of notifications:
addCritical()
– 🔴 CriticaladdMajor()
– 🟠 MajoraddMinor()
– 🟡 MinoraddNotice()
– 🔵 Notice
📋 Stored in Database
These notifications are stored in the adminnotification_inbox
table. You can manage them from the admin under:
Admin Panel → Bell Icon → Notifications
🔐 Tip: Use ACL to Target Roles
Although notifications are system-wide, you can conditionally insert them based on user roles if needed via custom logic.
✅ Summary
- Magento 2 provides a built-in admin notification system
- You can push messages using the
Inbox
model - Perfect for alerting admins about updates, licensing, or issues
Keep your module users in the loop with important backend alerts — the Magento way!