Pregunta

Esta pregunta ya tiene una respuesta aquí:

Mi pregunta es simple, la forma de conocer el caso de Magento que queremos enganchar?

¿Hay alguna solución sencilla?

¿Fue útil?

Solución

If you want to see the list of events that Magento has you have 3 options:

1) Google for it, there are a lot of people who have compiled a list of Magento events

2) Create a module that hooks on the controller_action_predispatch event which is the event that is called before any other event is called. Inside this module you can log each event that is dispatched:

Add the following on config.xml

<events>
    <controller_action_postdispatch>
        <observers>
            <controller_action_after>
                <class>yourmodule/observer</class>
                <method>hookToControllerActionPostDispatch</method>
            </controller_action_after>
        </observers>
    </controller_action_postdispatch>
</events>

And inside the yourmodule/Model/Observer:

public function hookToControllerActionPostDispatch($observer) {
    Mage::log($observer->getEvent()->getControllerAction()->getFullActionName());
}

The above would log every event that is dispatched...

3) If you have SSH access you can run the following command to get an overview of all the events (and their files where they are dispatched):

cd /path/to/<magento-root>
grep -nris 'dispatchEvent' app/code/

Otros consejos

The OnepageController dispatches an event for saving the shipping method. You could probably add your logic in there:

From OnepageController.php:

Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method',
                    array('request'=>$this->getRequest(),
                        'quote'=>$this->getOnepage()->getQuote()));

So, your event name is checkout_controller_onepage_save_shipping_method.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top