Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

AlexYakovlev

Новичок
  
  • Posts

    4
  • Joined

  • Last visited

AlexYakovlev's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In
  • Conversation Starter

Recent Badges

0

Reputation

  1. Попробуйте через систему событий.opencart-events-system и Докумениция
  2. Заметка Создаем 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
  3. Спасипотому что Как передать новые данные в view разобрался, но как добавить в twig новое поле пока не ясно. Вариант править в after output - изврат тот еещё)))
  4. Добрый гдень. После прочтения Докумениции вопросов врогде не осилось. Но при практическом применение все оказалось не ик как я ожидал. Вопрос в следуюещём: как используя систему событий добавить новое поле в карточке товара. Именно с использованием Events. Вот код при инсилляции: $code = "add_filed_before"; $trigger = "admin/controller/catalog/product/edit/before"; $action = "extension/module/test/add_filed_before"; $this->model_setting_event->addEvent($code, $trigger, $action); $code = "add_filed_after"; $trigger = "admin/controller/catalog/product/edit/after"; $action = "extension/module/test/add_filed_after"; $this->model_setting_event->addEvent($code, $trigger, $action); Вот обрилитлики: public function add_filed_before($route, $data) { $data['my_filed'] = 123; var_dump($data); } public function add_filed_after($route, &$data, $output) { var_dump($data); var_dump($output); } Да вот add_filed_before отрабатывает?, а add_filed_after Ожидал что отгдебажив что им в $data и $output бугдет понятно как гдействовать дальше. Но что то не заладилось. Причем с могделью все отрабатывает на ура.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.