我正在尝试处理 Opencart-3 中的事件以将数据移动到本地 ERP 系统。我创建了一个包含我需要处理的所有事件的扩展,我的问题是,只有与产品相关的事件被触发,而其他事件没有被触发。
<?php
class ControllerExtensionModuleErpIntegration extends Controller {
private $error = array();
public function index() {}
public function validate() {}
public function install() {
$this->load->model('setting/event');
$this->model_setting_event->addEvent('product_notification_add', 'admin/model/catalog/product/addProduct/after', 'extension/module/erp_integration/addProduct');
$this->model_setting_event->addEvent('product_notification_update', 'admin/model/catalog/product/editProduct/after', 'extension/module/erp_integration/editProduct');
$this->model_setting_event->addEvent('customer_notification_add', 'catalog/model/account/customer/addCustomer/after', 'extension/module/erp_integration/addCustomer');
$this->model_setting_event->addEvent('customer_notification_update', 'catalog/model/account/customer/editCustomer/after', 'extension/module/erp_integration/editCustomer');
$this->model_setting_event->addEvent('order_notification_add', 'catalog/model/checkout/order/addOrder/after', 'extension/module/erp_integration/addOrder');
}
public function uninstall() {
$this->load->model('setting/event');
$this->model_setting_event->deleteEventByCode('product_notification_add');
$this->model_setting_event->deleteEventByCode('product_notification_update');
$this->model_setting_event->deleteEventByCode('customer_notification_add');
$this->model_setting_event->deleteEventByCode('customer_notification_update');
$this->model_setting_event->deleteEventByCode('order_notification_add');
}
// admin/model/catalog/product/addProduct/after
public function addProduct(&$route, &$args, &$output) {
file_put_contents ( "testing.txt","\n******ADD PRODUCT**********\n" ,FILE_APPEND );
file_put_contents ( "testing.txt",print_r($args,true) . print_r($output,true) ,FILE_APPEND );
}
// admin/model/catalog/product/editProduct/after
public function editProduct(&$route, &$args, &$output) {
file_put_contents ( "testing.txt","\n******EDIT PRODUCT**********\n" ,FILE_APPEND );
file_put_contents ( "testing.txt",print_r($args,true) . print_r($output,true) ,FILE_APPEND );
}
// catalog/model/account/customer/addCustomer/after
public function addCustomer(&$route, &$args, &$output) {
file_put_contents ( "testing.txt","\n******ADD CUSTOMER**********\n" ,FILE_APPEND );
file_put_contents ( "testing.txt",print_r($args,true) . print_r($output,true) ,FILE_APPEND );
}
// catalog/model/account/customer/editCustomer/after
public function editCustomer(&$route, &$args, &$output) {
file_put_contents ( "testing.txt","\n******EDIT CUSTOMER**********\n" ,FILE_APPEND );
file_put_contents ( "testing.txt",print_r($args,true) . print_r($output,true) ,FILE_APPEND );
}
// catalog/model/checkout/order/addOrder/after
public function addOrder(&$route, &$args, &$output) {
file_put_contents ( "testing.txt","\n******ADD ORDER**********\n" ,FILE_APPEND );
file_put_contents ( "testing.txt",print_r($args,true) . print_r($output,true) ,FILE_APPEND );
}
}
我是否需要为目录部分(客户和产品事件)创建一个新的扩展,并将它们注册到不同的扩展中?或者我错过了什么。