5

So, I'm building a custom module to allow admins to define some custom business logic. I have most of it worked out at this point but I would like to tap into the admin action log that is included in Magento Enterprise Edition.

Is there a helper or model that automatically picks up the current user information (ID, time, IP, etc) and just allows me to specify the unique-to-my-module info?

2 Answers 2

7

You need to create a file called logging.xml in the etc folder of your module. where you should list your logged events. Take as example the logging.xml from the Enterprise_Logging module.
Should look something like this. Replace the markup with your own values:

<{entityCodeHere} translate="label">
    <label>{Entity Label here}</label>
    <expected_models>
        <{moduleName}__{entityName}/> <!-- replace the slash in the parameter you give to Mage::getModel() when instatiating the object with double underscore -->
    </expected_models>
    <actions>
        <adminhtml_{contrller}_{action}> <!-- or {module}_adminhtml_{contrller}_{action} . It depends on how the extension looks. It's basically the same as the layout handle for the page-->
            <action>{action}</action>
        </adminhtml_{contrller}_{action}>
     <!-- add as many actions as you want -->
    </actions>
</{entityCodeHere}> 

I hope I didn't miss something. Anyway, this is the right direction.

1
  • Oh wow. I should've guessed it would be XML based lol. I'll try this out and let you know. Thanks! Commented May 2, 2013 at 16:51
2

Important note here: Enterprise_Logging module logs events performed only with adminhtml route:

<controller_action_postdispatch_adminhtml>
    <observers>
        <enterprise_logging>
            <class>enterprise_logging/observer</class>
            <method>controllerPostdispatch</method>
        </enterprise_logging>
    </observers>
</controller_action_postdispatch_adminhtml>

If you have admin controller with custom router, you need to add additional observer to you module to call controllerPostdispatch method.

For example, if you have router called ordermanager:

<controller_action_postdispatch_ordermanager>
    <observers>
        <enterprise_logging>
            <class>enterprise_logging/observer</class>
            <method>controllerPostdispatch</method>
        </enterprise_logging>
    </observers>
</controller_action_postdispatch_ordermanager>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.