phpprestashopprestashop-1.7prestashop-modules

Prestashop admin redirection token


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));

Solution

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

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