Post by exttt » Sun Oct 06, 2024 12:52 pm

how and where to set the paths to custom api's in opencart4

Newbie

Posts

Joined
Mon Apr 11, 2016 12:42 pm

Post by exttt » Mon Oct 07, 2024 12:52 am

in /catalog/controller/startup/api.php - i changed the code:

Code: Select all

public function index(): object|null {
        $action = null;

        // Проверка за зададен маршрут
        if (isset($this->request->get['route'])) {
            $route = (string)$this->request->get['route'];

            // Проверка за конкретния API маршрут
            if ($route == 'api/sync/getAllProducts') {
                $action = new \Opencart\System\Engine\Action('api/sync/getAllProducts');
            } elseif ($route == 'api/sync/importProduct') {
                $action = new \Opencart\System\Engine\Action('api/sync/importProduct');
            } elseif ($route == 'api/sync/editProduct') {
                $action = new \Opencart\System\Engine\Action('api/sync/editProduct');
            } elseif ($route == 'api/sync/deleteProduct') {
                $action = new \Opencart\System\Engine\Action('api/sync/deleteProduct');
            }
        }

        // Проверка за валиден API токен
        if (substr($route, 0, 4) == 'api/' && $route !== 'api/account/login' && !isset($this->session->data['api_id'])) {
            return new \Opencart\System\Engine\Action('error/permission');
        }

        return $action;
    }
but I have no success
404 - GET: https://mydomain/index.php?route=api/sy ... 8f5909dacc

Newbie

Posts

Joined
Mon Apr 11, 2016 12:42 pm
Who is online

Users browsing this forum: No registered users and 2 guests