1

Eg I have a block that is on the page to edit the purchase order, both the editing page of the order as the block passes through the event sales_order_load_after when obeserver the event can not know what they spent for the event, if it was page or block.

How to know who called or went by event?

I have a fraud clearsales module, this module is on the order page to check I just click on the button analyze, when I click on it, it passes the event "sales_order_load_after" need to know who is passing by the magnitude of the event is ClearSale or page, I know that the two are going through the event as a test print.

enter image description here

config.xml:

<adminhtml>
        <events>
            <sales_order_load_after>
                <observers>
                    <ceicom_managesale>
                        <class>ceicom_managesale/observer</class>
                        <method>someMethod</method>
                    </ceicom_managesale>
                </observers>
            </sales_order_load_after>
        </events>
    </adminhtml>

Observer:

<?php

class Ceicom_ManageSale_Model_Observer
{
    public function someMethod($observer)
    {
        echo("teste");
    }
}
  • Can you add some concrete examples or code to your question to clarify what you're asking? on a side note: events are, as far as I know, rarely called from a block, only from controllers and models. – Sander Mangel Mar 13 '14 at 20:51
  • I added more information – Jonatan Ribeiro dos Santos Mar 13 '14 at 21:09
1

Events like *_load_after have no information where or by whom they were called.

But using request object you can get area, mudule, controller and action name and check them as you want.

    $oArea           = Mage::app()->getArea();
    $oRequest        = Mage::app()->getRequest();
    $sModuleName     = $oRequest->getModuleName();
    $sControllerName = $oRequest->getControllerName();
    $sAtionName      = $oRequest->getActionName();

But you will have problem if some model (in your case sales_order) can be called twice on the same page.

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.