Jump to content

Get product id in custom front office controller


Recommended Posts

Hi everyone I have created a custom front controller. I have a button in the displayreassurance hook inside the product page that calls that front controller. I want to send the product data to that controller.

 

$product = new Product(
    (int)Tools::getValue('id_product'),
    true,
    $this->context->language->id,
    $this->context->shop->id
);

Media::addJsDef(array(
    'product_name' => $product->name,
));

If I write this in my front controller I get null. Any idea how I can get the product details in the front controller?

Link to comment
Share on other sites

  • 2 weeks later...
On 11/19/2017 at 4:49 PM, bellini13 said:

Tools::getValue('id_product'),

You can only use this if you are passing id_product as a parameter to your front controllers URL as a GET or POST parameter.  Are you doing that?

I have just added this code inside the header and was trying to pass the product name to a controller through javascript file by assigning it.

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