Prestashop admin redirection tokken

210 views Asked by At

I have a custom module on Prestashop and I need to do a link to redirect to the product edit page, but can't find the way to get a token. I tried options with Tools class, but it's not working for me.

PHP version 8.1 Prestashop version 8.0.4

Tools::getAdminTokenLite('AdminProducts')
$token=Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee));
$token=Tools::getAdminToken('[classname]'.intval(Tab::getIdFromClassName('[classname]')).intval($params['cookie']->id_employee));
1

There are 1 answers

0
Artem Felbush On BEST ANSWER

You can use the link generator for the admin panel in PrestaShop.

$productEditUrl = $this->context->link->getAdminLink(
    'AdminProducts', 
    true, 
    ['id_product' => 999, 'updateproduct' => 1]
);