Заметка
Создаем admin\controller\extension\module\test.php
<?
class ControllerExtensionModuleTest extends Controller
{
private $error = array();
public $action = [
"admin/controller/catalog/product/edit/before",
"admin/controller/catalog/product/edit/after",
"admin/view/catalog/product_form/before",
"admin/view/catalog/product_form/after",
"admin/model/catalog/product/getProduct/before",
"admin/model/catalog/product/getProduct/after"
];
public function index()
{
}
public function validate()
{
}
public function install()
{
$this->load->model("setting/event");
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting('module_test', ['module_test_status' => 1]);
foreach ($this->action as $trigger) {
$action = str_replace("/", "_", $trigger);
$this->model_setting_event->addEvent("1my_" . $action, $trigger, "extension/module/test/" . $action);
}
}
public function uninstall()
{
$this->load->model("setting/event");
$this->load->model('setting/setting');
$this->model_setting_setting->deleteSetting('module_test');
foreach ($this->action as $trigger) {
$this->model_setting_event->deleteEventByCode("1my_" . str_replace("/", "_", $trigger));
}
}
public function Log($file_name, $var, $var_name)
{
ob_start();
echo $var_name . "\n\t";
var_dump($var);
file_put_contents(DIR_LOGS . $file_name . ".log", ob_get_clean() . "\n", FILE_APPEND);
}
public function admin_controller_catalog_product_edit_before(&$route, &$args = [])
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
}
public function admin_controller_catalog_product_edit_after(&$route, &$args = [], &$output = null)
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
$this->Log(__FUNCTION__, $output, "output");
}
public function admin_view_catalog_product_form_before(&$route, &$args = [])
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
}
public function admin_view_catalog_product_form_after(&$route, &$args = [], &$output = null)
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
$this->Log(__FUNCTION__, $output, "output");
}
public function admin_model_catalog_product_getProduct_before(&$route, &$args = [])
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
}
public function admin_model_catalog_product_getProduct_after(&$route, &$args = [], &$output = null)
{
file_put_contents(DIR_LOGS . __FUNCTION__ . ".log", "\n");
$this->Log(__FUNCTION__, $route, "route");
$this->Log(__FUNCTION__, $args, "args");
$this->Log(__FUNCTION__, $output, "output");
}
}
Устанавливаем расширение, проверяем events list, заходим в карточку товара. После можно анализировать что появилось в storage/logs/admin_*.log