Hi,
The trigger
admin/view/catalog/product_form/after is a view-based event that is fired after rendering the product form in the admin panel. OpenCart automatically supports admin/view/ events because it hooks into the rendering system.
The trigger
admin/model/catalog/product/addProduct/after is a model-based event, meaning it should trigger after the addProduct() method is called. However, OpenCart does not automatically trigger model events unless they are explicitly registered and executed inside the model.
To make admin/model/catalog/product/addProduct/after work, follow these steps:
Step 1: Ensure the Event is Registered in the Database. If it's missing, try "$this->model_setting_event->deleteEventByCode" before the addEvent function call. This will ensure that the event is registered in the Database properly.
Step 2: Modify the method "addProduct()" (in the file, admin/model/catalog/product.php) to manually fire the event, by adding this line at the end:
Code: Select all
$this->event->trigger('admin/model/catalog/product/addProduct/after', array(&$data));
Alternatively, If the event still does not trigger, try logging the event execution, for the same use the below code as follows:
Code: Select all
public function index(&$route, &$args, &$output) {
file_put_contents(DIR_LOGS . 'event_log.txt', "Triggered: $route\n", FILE_APPEND);
}
This will create a log file in
"/storage/logs/event_log.txt" where you can check if the event is being triggered.
Please review the above information and let us know in case of any queries.
Regards,
Knowband team