I have been searching for a solution for extending default Magento email functionality in order to send internal messages from Admin user to Admin user.

I haven't found any good resources on how to achieve this or what "events" I could hook into or Observe in order to set this up.

Would anyone happen to know what steps I could take to begin developing a module for sending internal messages between Admins?

I would be grateful even the smallest of guidance.

  • 1
    Real-time messaging? Or an interface to create system-wide notifications? – philwinkle Jun 18 '13 at 15:08
  • @philwinkle I am looking for a Real-time solution in order to communicate between Admins so there will be a need for an inbox etc... is it possible to do with existing events? – user1704524 Jun 18 '13 at 15:14
  • I don't mean to be rude (but I probably am - sorry for that), you are trying to reinvent the wheel. Make them use a chat software (skype, gtalk, even yahoo messenger). I don't see the point of this. Maybe I don't have the big picture. – Marius Jun 18 '13 at 16:39
  • @Marius thanks you are not being rude at all and I share your opinion. However, the requirement is from a customer services point of view whereby all communication between admin agents can be logged and monitored... – user1704524 Jun 18 '13 at 18:33
  • 1
    In that case using a ticketing system like JIRA, OTRS, Trac, or one of a million others would be a good choice. – Vinai Jun 18 '13 at 21:10

If you really don't want to use email or jabber (which can easily be logged by a company) or a ticket system, follow this process to implement your requirements:

  1. Create a new module
  2. Create a table (id, recipient, content, is_received, ...) using a module setup script
  3. Create a backend page that admins can use to send messages (create records in the table)
  4. Create an event observer for controller_action_predispatch in the adminhtml area.
  5. In the event observer method, check if the admin is logged in. If so, fetch pending messages for the current admin user.
  6. Add the messages to the session to display them.

Something like this (concept code):

$session = Mage::getSingleton('admin/session');
if ($session->isLoggedIn()) {
    $messages = Mage::getResourceModel('my_module/message_collection')
        ->addFieldToFilter('recipient', $session->getUser()->getUsername())
        ->addFieldToFilter('is_received', 0);
    $helper = Mage::helper('my_module');
    foreach ($messages as $message) {
        $sender = $helper->escapeHtml($message->getSender());
        $msg = $helper->escapeHtml($message->getContent());
        $session->addNotice("[FROM: {$sender}] $msg"); 
    $messages->setDataToAll('is_received', 1)->save();
| improve this answer | |
  • thanks for the guide and the code you have shared. I will start the module and let you know how I get on. – user1704524 Jun 19 '13 at 9:55

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.