Magento 2 use show Success and Error Message Using Interface Magento\Framework\Message\ManagerInterface.
You can set success message Using addSuccessMessage( ) and set error message using addErrorMessage( )function.
You can directly fetch Object of Magento\Framework\Message\ManagerInterface in controller file but for other files like Plugin, Observer, Model, Block or Helper; you need to instantiate an object in your __construct( ) method.
1 2 3 4 5 |
public function __construct( \Magento\Framework\Message\ManagerInterface $messageManager ) { $this->messageManager = $messageManager; } |
Now you can set messages like below:
1 2 |
$yourMessage = __('Your Error Message'); $this->messageManager->addErrorMessage($message); |
1 2 |
$yourMessage = __('Your Warning Message'); $this->messageManager->addWarningMessage($message); |
1 2 |
$yourMessage = __('Your Notice Message'); $this->messageManager->addNoticeMessage($message); |
[crayon-63d3e5958c949860486528/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.