straightlight wrote: ↑Thu May 02, 2019 12:20 am
You are still using the underscore with the method so not sure which method name you are using now …
However, you could use the same example as already queried for the order ID in the catalog/controller/event/activity.php file under the addOrderHistory method.
Ok, so here's what I've changed and tried.
Using this for the event -
Code: Select all
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`) VALUES ('post_order', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/module/post_order/postorderdata', 1);
And this for the function -
Code: Select all
<?php
class ControllerExtensionModulePostOrder extends Controller {
public function postOrderData(&$route, &$args, &$output) {
ob_start();
var_dump($route);
$dump_route = ob_get_clean();
ob_start();
var_dump($args);
$dump_args = ob_get_clean();
ob_start();
var_dump($output);
$dump_output = ob_get_clean();
ob_start();
var_dump($this);
$dump_this = ob_get_clean();
$data_dump = "ROUTE:\n$dump_route\n\nARGS:\n$dump_args\n\nOUTPUT:\n$dump_output\n\nTHIS:\n$dump_this\n\n";
//$order_id = $args[0];
//$this->load->model('checkout/order');
//$orderinfo = $this->model_checkout_order->getOrder($order_id);
//ob_start();
//var_dump($orderinfo);
//$data_dump = ob_get_clean();
file_put_contents('/var/www/html/test.txt', $data_dump );
}
}
Everything works. The only change above is I took out the underscores in the function name. I know I can call the commented out section in that function and it returns the order info, but I also see that the order info is already in the variable $this so it seems really sloppy to do another call to retrieve the information that is already in $this. I'm hoping I can retrieve that information without making another call?
If I'm understanding your other comment right, I tried changing
Code: Select all
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`) VALUES ('post_order', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/module/post_order/postorderdata', 1);
To this
Code: Select all
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`) VALUES ('post_order', 'catalog/controller/event/activity/addOrderHistory/after', 'extension/module/post_order/postorderdata', 1);
And I also tried
Code: Select all
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`) VALUES ('post_order', 'catalog/controller/event/activity/addOrderHistory/before', 'extension/module/post_order/postorderdata', 1);
But both of those different events didn't seem to do anything, so maybe I'm just not understanding what you're trying to explain?