Success Message Not Display

In Controller :-

public function execute()

      $delid = $this->getRequest()->getParam('id');

         $user = $this->_userFactory->create();
         }catch (\Exception $e){

        $this->messageManager->addSuccessMessage(__('Record Deleted   

enter image description here

Thanks in advance:)

  • check class="page messages" exist in page or not. – Padhiyar Gaurang Dec 20 '19 at 8:56

Working with message manager

Messaging in Magento 2 is handled by a message manager object. So if you want to write messages, you need to get an instance of it. The prefered method is to inject this class into your class by adding this to your __construct method:

protected messageManager;

public function __construct(
    \Magento\Framework\Message\ManagerInterface $messageManager,
    $this->messageManager = $messageManager;

With this, you can call one of the following messages: PHP


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.