Add Custom message using magento

How to add Custom Success message and add Error message in Magento Session 

You can add any custom Error message or Success message in magento session .If you are thinking to show an error message or success message one time when a page load then it is the best method to use in mganeto session .

 

Success message

Set success message for front page :

$message = $this->__('Got an error');
Mage::getSingleton('core/session')->addSuccess($message);

Set success message for admin page :

 

$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addSuccess($message);

 

If you are unable to view the error/success message, add the function session_write_close() after setting message. I got such problem while using with redirect method.

Now the new snippet will look like below,

$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addError($message);
session_write_close();

 

Notice Message

By this way we can show notice message by using addNotice().

 

$message = $this->__('Please note this modification');
Mage::getSingleton('core/session')->addNotice($message);

 

 

Error message

Set error message for front page :

$message = $this->__('Got an error');
Mage::getSingleton('core/session')->addError($message);

 

 

Set error message for admin page.

$message = $this->__('Got an error');
Mage::getSingleton('adminhtml/session')->addError($message);

 

 

 

 

 

 

 

 

7 thoughts on “Add Custom message using magento

  1. in custom module admin side wher error message shows  duplicate data saved

    and when message not shows  data not saved

  2. Good site you have here.. It’s hard to find good quality writing like
    yours nowadays. I seriously appreciate individuals
    like you! Take care!!

  3. Hello! This is my 1st comment here so I just wanted to give a quick shout out and say I really enjoy reading your blog posts.
    Can you suggest any other blogs/websites/forums that go
    over the same subjects? Appreciate it!

  4. Hello there! Do you use Twitter? I’d like to follow you if that
    would be okay. I’m undoubtedly enjoying your blog
    and look forward to new updates.

  5. Hello AdeshSuryan,

    I am using Magento CE 1.9.2.4. I had purchased intenso theme and had installed on my server. But I am having problem in Newsletter Subscription. I want to modify it, but how to do it. I am not well-versed in it. Can you please guide me in it.

    Awaiting for your response.

    Regards,

    Nidhi

     

Leave a Reply

Your email address will not be published.