Jump to content

[SOLVED] Getting id_product in the controller from hook


Recommended Posts

Hi, everyone.
I have module that is using admin controller to do some stuff, in there i call database and search for all products and it is working fine.
What i want is to get the current id_product from hookDisplayAdminProductsExtra but I cant call that in controller. Even thou i use Hook::exec
The function does not even get executed since i am not calling it form module but from hook.
So what i want is to get id_product from hooks $params and pass it to controller and use it as argument when doing db search

prestashop 1.7.6.7
php 7.2
Solved by using ajax passing the data from smarty tpl to controller

Edited by feho1 (see edit history)
Link to comment
Share on other sites

Working on assumption here. In you module you redirect to your controller like this?

Tools::redirectAdmin($this->context->link->getAdminLink('AdminYourController'));

getAdminLink full declaration is:

Link::getAdminLink($controller, $withToken = true, $sfRouteParams = array(), $params = array())

If you call it with

$params['id_product'] = $id_product;

You can access that value in your controller with

$id_product = Tools::getValue("id_product");

Don't forget to check if the id_product value is set to begin with (Tools::getIsset('id_product')).

rg,

Leo

  • Like 1
Link to comment
Share on other sites

  • feho1 changed the title to [SOLVED] Getting id_product in the controller from hook

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...