0
votes


I need to extend AdminPdfControllerCore in a PS module I'm developping, to generate a PDF file. I created a controller in MY_MODULE/controllers/admin/AdminPdfCustomController.php

class AdminPdfCustomController extends AdminPdfControllerCore{

public function postProcess(){
    parent::postProcess();
}

public function initProcess() {
   error_log('AdminPDFCustomAction / INIT PROCESS / => ' . Tools::getValue('submitAction'));

   parent::initProcess();
}

public function processGenerateTechnicalsheetPdf(){

}

}

I want to access my controller in the Admin interface via an URL like index.php?controller=AdminPdfCustom&fc=module&module=jtechnicalsheet&submitAction=generateTechnicalsheetPdf&id_order=1&token=[...]

But I have a 404 error message. am I writing my controller the right way ? Can someone help me in the way to write the URL ? I'm using PS 1.7.4.1.

Thank you,

Gildas

1
does the link have the admin folder? Also, i think (from the existing examples) you only need the vars controller and token. Like [domain]/[adminfolder]/index.php?controller=AdminPdfCustom&token=[token] - sadlyblue
Yes, my full path includes admin folder [base_url]/admin1234abcd/index.php?controller=AdminPdfCustom&&token=[token] - Gildas
If you want to extend AdminPdfControllerCore, you need to create an override for that class in module/override/controllers/admin that will be copied on install to /override/controllers/admin. But if you want to create a controller in your module to be accessbile from that link, it should extend ModuleAdminController. - sadlyblue

1 Answers

0
votes

Thank you, I check it and I can access the necessary PDF methods by extend ModuleAdminController and use initContent() method inside. So my URL works with controller + token + myVars.

class AdminPdfCustomController extends ModuleAdminController{

    public function initContent()
    {
        parent::initContent();

        /** here comes my code **/
    }
}

admin_path/index.php?controller=AdminPdfCustom&fc=module&module=jtechnicalsheet&id_order=1&token=[...]