Answer the question
In order to leave comments, you need to log in
How to add an event in opencart 3.x?
You need to add an event that adds the word "Test" to the product name on the product page.
admin/controller/extension/my_module.php:
class ControllerExtensionModuleMyModule extends Controller {
public function install() {
$this->load->model('setting/event');
$this->model_setting_event->addEvent('my_module', 'catalog/view/theme/default/product/product/before', 'extension/module/my_module/index');
}
public function uninstall() {
$this->load->model('setting/event');
$this->model_setting_event->deleteEventByCode('my_module');
}
}
class ControllerExtensionModuleMyModule extends Controller {
public function index(&$route, &$data){
if ($data && isset($this->request->get['product_id'])) {
$data['heading_title'] = $data['heading_title'] . " TEST";
return $data;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question