Helow,
I'm trying to create a manual event in my database that redirects the getApiByToken method within the model setting/api.getApiByToken and it doesn't work at all. Are there any restrictions?
[ oc_event ]
TRIGGER: catalog/model/setting/api.getApiByToken/after
ACTION: extension/rest/setting/api.getApiByToken
<?php
namespace Opencart\Catalog\Model\Extension\Rest\Setting;
class Api extends \Opencart\System\Engine\Model {
public function getApiByToken(string $token): array {
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "api` a LEFT JOIN `" . DB_PREFIX . "api_session` `as` ON (a.`api_id` = `as`.`api_id`) LEFT JOIN `" . DB_PREFIX . "api_ip` ai ON (a.`api_id` = ai.`api_id`) WHERE a.`status` = '1' AND `as`.`session_id` = '" . $this->db->escape((string)$token) . "'");
return $query->row;
}
}
Have you tried a trigger of catalog/model/setting/api/getApiByToken/after? Also try your event as a controller.
AddCreative is right. The event handler needs to be in a controller class, e.g.:
Code: Select all
<?php
namespace Opencart\Catalog\Controller\Extension\Rest\Other;
class Rest extends \Opencart\System\Engine\Controller {
// event handler for trigger catalog/model/setting/api/getApiByToken/after
public function eventModelSettingApiGetApiByTokenAfter(string &$route, array &$args, mixed &$output): void {
if (!$this->config->get('other_rest_status')) {
return;
}
$token = $args[0];
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "api` a LEFT JOIN `" . DB_PREFIX . "api_session` `as` ON (a.`api_id` = `as`.`api_id`) LEFT JOIN `" . DB_PREFIX . "api_ip` ai ON (a.`api_id` = ai.`api_id`) WHERE a.`status` = '1' AND `as`.`session_id` = '" . $this->db->escape((string)$token) . "'");
if ($output) {
$output = $query->row;
}
}
// more event handlers for your rest extension ....
}
?>
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Who is online
Users browsing this forum: Semrush [Bot] and 10 guests