Thiago Quadros Posted June 29, 2011 Posted June 29, 2011 Hi,this is my last choice. I'm trying seek information in full internet.Well, going to the question:I'm trying get the ID of the current Employee logged. All method type, returned me a void sentence.Example:$_POST['id_employee']$cookie->id_employeeand many others bad choices of codes.Please, I'm needing help!source code is in attachment.tks... ab_prod.php Share this post Link to post Share on other sites More sharing options...
Richard S Posted June 29, 2011 Posted June 29, 2011 $cookie->id_employeeShould worked, if I remember good, maybe you forget to make it global in the method? Share this post Link to post Share on other sites More sharing options...
MahmutGulerce Posted June 29, 2011 Posted June 29, 2011 hi;could you try print_r($cookie); Other hand you must set cookie to global in class functions declarations Like function SampleFunction ($arg) { global $cookie; // Now you can use cookie // return (int)$cookie->id_employee; } Share this post Link to post Share on other sites More sharing options...
Thiago Quadros Posted June 29, 2011 Posted June 29, 2011 very, very, very thanks.The "global" reserved word that is a great solution.Thanks. Share this post Link to post Share on other sites More sharing options...
MahmutGulerce Posted June 29, 2011 Posted June 29, 2011 very, very, very thanks.The "global" reserved word that is a great solution.Thanks. I'm so glad it had worked Share this post Link to post Share on other sites More sharing options...
Prestadget Posted November 22, 2012 Posted November 22, 2012 I'm so glad it had worked Sorry for the old post, but I came accros it from Google, so, a better anwser : Prestashop uses 2 cookies, one for Front and one for Backoffice. The backoffice cookie is named "psAdmin", encoded with a MD5 and contains the employee_id. So your solution is only working under /admin folder ! If you want to retrieve the employee_id outside it, you need to create a new Cookie('psAdmin') Share this post Link to post Share on other sites More sharing options...
Ricardo Vigatti Posted September 20, 2013 Posted September 20, 2013 Sorry for the old post, but I came accros it from Google, so, a better anwser : Prestashop uses 2 cookies, one for Front and one for Backoffice. The backoffice cookie is named "psAdmin", encoded with a MD5 and contains the employee_id. So your solution is only working under /admin folder ! If you want to retrieve the employee_id outside it, you need to create a new Cookie('psAdmin') Prestadget, i can't understand what you told about the backoffice cookie, can you please help us on how to use it ? For now, i'm using the "global $cookie" and it's working Share this post Link to post Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Posted June 23, 2014 Hi I am trying to use this for my standarad php coding but I am unable to access this id_employee variable..I am trying to use it for standard php code. I want to save the id_employee in a new $id variable please help. Share this post Link to post Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Posted June 23, 2014 $id = ((int)$cookie->id_employee); this returns me zero value Share this post Link to post Share on other sites More sharing options...
vekia Posted June 25, 2014 Posted June 25, 2014 you have to define global cookie. global $cookie; $cokie->id_employee; Share this post Link to post Share on other sites More sharing options...
karthiiiiiiiiiik Posted September 1, 2014 Posted September 1, 2014 how to do i get the employee id in tpl file ... Share this post Link to post Share on other sites More sharing options...
aquahuang Posted February 3, 2016 Posted February 3, 2016 put this {$employee->id} in .tpl Share this post Link to post Share on other sites More sharing options...
serfer2 Posted March 28, 2016 Posted March 28, 2016 For Prestashop >= 1.5 you must use "Context" class (read the docs). In example (inside a module code): $employee_id = $this->context->employee->id; or: $ctx = Context::getContext(); $emp_id = (int)$ctx->employee->id; Hope it helps ;-) Share this post Link to post Share on other sites More sharing options...
Klemart3D Posted July 6, 2016 Posted July 6, 2016 print_r($this->context->employee->id); Fatal error: Using $this when not in object context Share this post Link to post Share on other sites More sharing options...
Jihene Heni Posted April 2, 2018 Posted April 2, 2018 comment recuperer id_employee pour prestashop 1.7 Share this post Link to post Share on other sites More sharing options...
Pierre Belin Posted October 28, 2019 Posted October 28, 2019 On 3/28/2016 at 9:53 AM, serfer2 said: For Prestashop >= 1.5 you must use "Context" class (read the docs). In example (inside a module code): $employee_id = $this->context->employee->id; It's exactly the same in PrestaShop 1.7. If you want to get the employee ID in a hook, you have to call it that way : $id_employee = Context::getContext()->employee->id; Share this post Link to post Share on other sites More sharing options...
oldmanxxxv Posted December 9, 2021 Posted December 9, 2021 Hi there. Is there any any of you who knows how to get in Prestashop 1.7.8 in admin area, order template twig page the employee id and the token generated for that page? I'm kind of stuck here. Thanks! Share this post Link to post Share on other sites More sharing options...
ZiedDams Posted January 13, 2022 Posted January 13, 2022 On 10/28/2019 at 4:54 AM, Pierre Belin said: It's exactly the same in PrestaShop 1.7. If you want to get the employee ID in a hook, you have to call it that way : $id_employee = Context::getContext()->employee->id; employee variable is 'NULL' while I'm a superAdmin Connected Share this post Link to post Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now