Opencart 4 Extension Route throws 404

355 views Asked by At

I'm trying to develop an Opencart4 Extension and for some reason it's throwing a 404 when I try to access it.

I've the following structure:

/opencart/extensions/myextension/admin/controller/payment/myextension.php /opencart/extensions/myextension/admin/template/payment/myextension.twig

and here's the controller:

<?PHP

namespace Opencart\Admin\Controller\Extension\MyExtension\Payment;

class MyExtension extends \Opencart\System\Engine\Controller {

   public function index() {

        $data = array();

        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/myextension/payment/myextension', $data));
   }
}

Now when I try to access the http://localhost/admin123/index.php?route=extension/myextension/payment/myextension, I get a 404 page!

Screenshot

2

There are 2 answers

1
K. B. On

template must be twig file:

/opencart/extensions/myextension/admin/template/payment/myextension.twig
0
Maksim Gerasimenko On

that works extension in opencart 4, before need compile your extension to

myextension.ocmod.zip

and then install from admin, then should works.

this is correct structure.

enter image description here