Prestashop module redirection error

1.5k Views Asked by At

I'm programming a module for Prestashop. It's working fine, except for a redirection link.

This is the code:

Tools::redirectLink(__PS_BASE_URI__.'modules/mymodule/page.php?err=f&key='.$rid_key.'&id_cart='.$rid_cart.'&id_module='.$rid_module.'&id_order='.$rid_order);

Then the browser redirects to:

http://mydomain/index.php?controller=modules/mymodule/page?err=f&key=c0acad8c21e44ed574df023c1dd11c17&id_cart=93&id_module=86&id_order=934251

But this generates a prestashop 404 not found.

I'm a bit lost.

I have enabled debug in settings, but no error is displayed. Any idea of how to debug this?

1

There are 1 best solutions below

0
On

There is a work around to simply do the same as you want.

Just paste the code you want to run in page.php into a new controller and them (in function initContent()) as follows:

class YourModuleNameManagerModuleFrontController extends ModuleFrontController
{

    public function initContent()
    {
        parent::initContent();
        // Your Code Here
    }
}

Now call this controller instead of the file page.php and it will work fine.