Comments on: Magento Events Explained and a few Gotchas avoided! http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/ Notes on Web Development Wed, 23 Dec 2020 09:25:05 +0000 hourly 1 https://wordpress.org/?v=4.8.15 By: Humayun http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-9794 Tue, 12 Mar 2013 23:22:24 +0000 http://www.aschroder.com/?p=598#comment-9794 Cool post!
I have a weird situation. I am trying to hook on to sales_order_save_after event but it won’t work. To debug this I am doing Mage::log in Mage.php to see what events are firing. Suprirsing, its on printing ‘resource_get_tablename’ and ‘core_collection_abstract_load_before’ and ‘after’ few times (24 lines altogether) and nothing else. To make it more confusing, when I save a product (by going Manage Products) its prints all big list of all the events (its suppose to). Any idea how to debug this? I want to send an email out on sales_order_save_after event.

]]>
By: prat http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-3558 Tue, 13 Mar 2012 19:44:31 +0000 http://www.aschroder.com/?p=598#comment-3558 HI Ashley,
It’s really very informative & useful article. I wanted to know more about event-observer model of Magento.
Currently I am focussing on sales order placement event. I have created one custom table in Magento that contains different sales order related columns(like increment id from sales_flat_order, item_name,sku from sales_flat_order_item etc.). I connected to mysql database through PHP. I join these table to form a single query & put this query which fetches & inserts data into custom table.
Now my ultimate aim is once customer places order, this php file must get called so that all data fetched through that query get inserted into custom table…
So how event-observer model I can use for the same…do u have any sample code for the same…
Plz guide me…

Regards,
Prat

]]>
By: Magento http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-2996 Fri, 24 Feb 2012 08:09:18 +0000 http://www.aschroder.com/?p=598#comment-2996 Hello,Ashley. Thanks for your great post! I have a question here, I searched magento app folder for “checkout_submit_all_after” event, it was fired in lots of places in Magento Core code. As I know, Magento just run one time of the same event in one request. So why I can still use this event in my own module in local code?

Sorry for my pool English 🙂 Thanks in advanced.

]]>
By: Ashley http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-2918 Thu, 02 Feb 2012 22:05:03 +0000 http://www.aschroder.com/?p=598#comment-2918 Troll much? Did you read the section of the article titled:
“Why is my Observer not firing – Config areas in Magento”

The code is in that section:
Mage::app()->loadArea();

]]>
By: Michael C. http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-2917 Thu, 02 Feb 2012 21:17:37 +0000 http://www.aschroder.com/?p=598#comment-2917 Ashley,

You completely forgot to mention the part about the “config area.” You talked about your observer’s callback not getting called in command-line context; then you pointed out some code in the parent. But you never said anything else. Can you provide working sample snippets showing your final config.xml and observer class?

]]>
By: philippe http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1962 Sat, 13 Nov 2010 17:17:33 +0000 http://www.aschroder.com/?p=598#comment-1962 Same problem here. Using magento 1.4.1.1 and “checkout_onepage_controller_success_action” never seems to fire. Done debugging until the app() function call in Mage.php, but can’t find the problem

]]>
By: Jamaal http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1467 Sun, 27 Jun 2010 04:14:04 +0000 http://www.aschroder.com/?p=598#comment-1467 Thanks Ashley, just sent you an email!

-jamaal

]]>
By: Ashley http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1466 Sat, 26 Jun 2010 23:59:25 +0000 http://www.aschroder.com/?p=598#comment-1466 The comment had all your formatting stripped – flick me an email and I’ll run an eye over that config.xml – the php code you pasted in doesn’t look quite right either, but that may be related to the comment formatting.

]]>
By: Jamaal http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1462 Sat, 26 Jun 2010 07:02:14 +0000 http://www.aschroder.com/?p=598#comment-1462 I’m still so confused about this. I am trying to get checkout_onepage_controller_success_action to work when someone checks out I need to send some SOAP data to someone else. However it never fires!

I’ve RTFM’ed so many times and can’t figure out what’s wrong.

[root@VO12044 etc]# cat config.xml

0.1.0

MyCompany_MyModule_Helper

<!– –>

model
MyCompany_MyModule_Helper_MyFunction
setMyFuction

in app/code/local/MyCompany/MyModule/Helper

[root@VO12044 Helper]# cat MyFunction.php
getEvent()->getOrder();
foreach ($order->getAllItems() as $item) {
$fname = ($_SERVER[‘DOCUMENT_ROOT’].’orders.txt’);
$fhandle = fopen($fname,”a”);
fwrite($fhandle,$item);
fwrite($fhandle,”BLAH”);
fclose($fhandle);
//echo $order->getStatus();
//echo $content;

}

//$event = $observer->getEvent();
//$order = $event->getOrder();
//$customer = $event->getCustomer();

//file_put_contents($_SERVER[‘DOCUMENT_ROOT’].’/_db_backups/array.txt’, serialize(base64_encode($order)));
//return;
}
}
//

I can’t figure out what im doing wrong. HALP!

jamaal@cellyeah.com

]]>
By: xer0x http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1392 Wed, 02 Jun 2010 20:40:20 +0000 http://www.aschroder.com/?p=598#comment-1392 Thanks this helped a ton

]]>