1

I've seen multiple types of messages on magento 2. Error messages, success messages and so on. How can I get the total number of messages that magento can provide? It should be sum of messages displayed on each and every scenario.

How can I get that exact amount?

2

You can check all available messages in Magento, Check below file

vendor/magento/framework/Message/ManagerInterface.php

List of messages in Magento

addMessage

addMessages

addError

addWarning

addNotice

addSuccess

addErrorMessage

addWarningMessage

addNoticeMessage

addSuccessMessage

addComplexErrorMessage

addComplexWarningMessage

addComplexNoticeMessage

addComplexSuccessMessage

addUniqueMessages

addException

addExceptionMessag

0

Mostly we need below messages, that you can display for viewing purpose like this

<?php 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$messageManager = $objectManager->create('\Magento\Framework\Message\ManagerInterface');
$messageManager->addError('This is Error Message');
$messageManager->addSuccess('This is Success Message');
$messageManager->addNotice('This is Notice Message');
$messageManager->addWarning('This is Warning Message');
?>

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.