Jump to content
Kegon

How to generate/get AdminProducts token in PrestaShop 1.7.x

Recommended Posts

Hi

I am trying to develop a module to help list products in various situations. How do I generate a token for at direct product link with PS 1.7.x? I can't seem to find any examples that helps.

I can generate tokens for customers and other stuff which works - and those tokens seems to be md5, but the tokens for AdminProducts seems to be another type of hash, like "HK5Z6KMpx_EP6-ykNM2Ju1QAkOqlFmskolAe3IXt8ss". Any help anyone?

Thanks for your answer.

Share this post


Link to post
Share on other sites

Hi, did you succeed with your issue? I'm currently having very similar problem, as I need to send my token from AdminProducts to my custom controller and I always receive token validation error in response.

Share this post


Link to post
Share on other sites

Hello, can anyone provide some informations on this subject? I saw some solutions similar to

 

$tokenProducts = Tools::getAdminToken(
            'AdminProducts'.
            (int)Tab::getIdFromClassName('AdminProducts').
            (int)$this->context->employee->id
        );

 

but the code I receive is always different from the one i see in the url in my browser after the _token parameter: index.php/product/catalog?_token=DIFFERENT_CODE_HERE

 

Edit: nevermind, have a look here.

Edited by Uff182 (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)

And if somebody wondering how just to generate a token, you can use:

Tools::getAdminTokenLite('AdminOrders')

 

Edited by soduno (see edit history)

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More