I have create a observer, before edit button click event are occurred. using this I could change the value of select box
I have create a observer, before edit button click event are occurred. using this I could change the value of select box
For an observer to be called, two things should exist, an event and an $observer which listens to that event. To set an observer on an event simply google, you will find out how.
If you wanna debug your observer,there are two important methods you can watch to understand what's going on. The first one is Mage_Core_Model_App#dispatchEvent at app/code/core/Mage/Core/Model/App.php:1271
public function dispatchEvent($eventName, $args)
{
$eventName = strtolower($eventName);
foreach ($this->_events as $area=>$events) {
// (...)
This is where all events has a stop on their way. During development, you can inspect the $eventName by setting a breakpoint here (my favorite), logging the value to a file, or even get very dirty and simply echo to see under the hood.
public function dispatchEvent($eventName, $args)
echo "BlaBlaBla"; // just used to find the printed lines in view source code of browser
print_r($eventName);
$eventName = strtolower($eventName);
foreach ($this->_events as $area=>$events) {
// (...)
Remember, you are editing core files, and this is just to explore and find the event name, get rid of these lines afterwards.
The second method which actually does the job is Mage_Core_Model_App#_callObserverMethod at app/code/core/Mage/Core/Model/App.php:1338
/**
* @param object $object
* @param string $method
* @param Varien_Event_Observer $observer
* @return Mage_Core_Model_App
* @throws Mage_Core_Exception
*/
protected function _callObserverMethod($object, $method, $observer)
{
if (method_exists($object, $method)) {
$object->$method($observer);
} elseif (Mage::getIsDeveloperMode()) {
Mage::throwException('Method "'.$method.'" is not defined in "'.get_class($object).'"');
}
return $this;
}
$object->$method($observer) will call the observer method on an object, just like before you can set a breakpoint, log to a file or even echo to see what's going on under the hood.
First find the event you are interested in, then try to add bind the event to the observer then, if not working, you can use the second method to debug.
And, yay.... Magento is never simple.