Jump to content

Generating an admin controller link


nicolas.espiau

Recommended Posts

Hi everyone,

 

I'm developing a module for which I need to generate a link to an action of the admin controller of the module.

 

I did not found documentation that helps me. I don't know the rules I have to follow to write an admin controller (name, syntax, ...), and mostly I don't know how to generate a secure link in an admin template.

 

More precisely, I've added a block on the admin order page in which I need to insert a link that execute an action of the module admin controller (this action has no view) and then refreshes (or redirects the user to) the admin order page.

The action calls a webservice to get information about the order (fraud screening system), and then update the score (fraud risk level) of the order in the database module table.

Obviously, i'd like this link to be secure (with token, or anything).

 

I tried with the LynkCore class (methods getModuleLink and getAdminLink) but it does not work, I did not understand how to use it properly.

 

 

Thanks a lot for your help.

 

PS : you will see attached a screenshot of the admin order page, on which I circled in red the link that has to execute the action described above.

post-442237-0-89653200-1358792310_thumb.png

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

I know i'm late (2 years late actually...)

 

I love your answer Axi, it works, but goes against Prestashop Architecture (In PS 1.6 and 1.5 I think, I don't know your version)

 

The access to Link class must be done via the context class. Creating multiple class of context's attribute is a bad pratice and goes against the "Context Pattern".

 

To get the link class in a controller :

$link = $this->context->link;

Best regards,

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...