Jump to content

Show hook execution result message in BackOffice


klimpond

Recommended Posts

Hello,

 

I would like to ask you, if it is possible to display a hook action result message in BackOffice.

 

I created 'ActionOrderStatusPostUpdate' hook function in my module and when all needed operations are performed I would like to inform user (employee in BackOffice) who changed the order status if the hook execution was successful or what went wrong.

 

As far as I checked the code, AdminOrderController calls OrderHistory->changeIdOrderState() which executes the transplanted modules 'ActionOrderStatusPostUpdate' hook.

 

But module has no context association to be able to inject error or confirmation message.

 

Please help.

Thanks

Link to comment
Share on other sites

you can for example use var_dump or print_r for your variables to check contents - then use die(); / break();

you will see the contents of the variables - so you will know something more about what's goin wrong

 

this is the my way to debug these hooks and my code :)

Link to comment
Share on other sites

Thank you for your answer, but what am I looking for is a user friendly back office solution, where administrator of the shop is informed about action results.

 

After more Prestashop source code digging, I found I can use in my hook functions like

$this->context->controller->errors[];

 

or

 

$this->$this->adminDisplayWarning($msg);

 

which is great, but in my case, after updating order status, there is performed a redirect, and as PHP is stateless, all messages are lost.

 

I was thinking about storing messages to session or cookie and then retrieving them on each page load, where messages are displayed to user and then removed from session/cookie.

 

Has Prestashop similar advanced message capabilities or I have to develop my own?

 

Thank you.

Link to comment
Share on other sites

ahh thanks for clarification, i just thought that you want to debug the code to find errors

i'm going to try something to my bo, i suppose that there is something to display messages, but i don't know exactly right now, so tests are necessary :)

Link to comment
Share on other sites

  • 4 months later...

you've got it in $params variable, 

 

in this hook try to use this:

echo "<pre>".print_r($params)."</pre>";die();

you will see then detailed informations about $params array (where you can find information about your order)

 

use this code only temporarily.

Link to comment
Share on other sites

Thank you vekia,

 

I am using the  hook actionorderstatuspostupdate -> while using this hook i am trying to get the order status of a order, after clicking the add button of status .. i am seeing the array values and it is not showing the currently selected status value, it shows the previous status before clicking the add button or change in the status. how to get the order status value after changing the status by clicking the add button in order page.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Thank you for your answer, but what am I looking for is a user friendly back office solution, where administrator of the shop is informed about action results.

 

After more Prestashop source code digging, I found I can use in my hook functions like

$this->context->controller->errors[];
or

 

$this->$this->adminDisplayWarning($msg);
which is great, but in my case, after updating order status, there is performed a redirect, and as PHP is stateless, all messages are lost.

 

I was thinking about storing messages to session or cookie and then retrieving them on each page load, where messages are displayed to user and then removed from session/cookie.

 

Has Prestashop similar advanced message capabilities or I have to develop my own?

 

Thank you.

 

 

 

I've the same Problem. Someone an good idea to solve this ?

 

Thanks.

Link to comment
Share on other sites

  • 1 month later...

you've got it in $params variable, 

 

in this hook try to use this:

echo "<pre>".print_r($params)."</pre>";die();

you will see then detailed informations about $params array (where you can find information about your order)

 

use this code only temporarily.

in don't see anything from $params:


function install()
{ 
       $this->registerHook('actionProductDelete')
}
function hookActionProductDelete($params){
		echo "<pre>".print_r($params)."</pre>";die();
		$file = fopen('D:\testnew_module_delete.txt', 'a+');
		fwrite($file, print_r($params,true));
		fclose($file);
	}

is what i'm doing wrong?

Link to comment
Share on other sites

Hello,

 

i am new with PrestaShop and my english is not the best, please consider this.

 

in don't see anything from $params:

function install()
{ 
       $this->registerHook('actionProductDelete')
}
function hookActionProductDelete($params){
		echo "<pre>".print_r($params)."</pre>";die();
		$file = fopen('D:\testnew_module_delete.txt', 'a+');
		fwrite($file, print_r($params,true));
		fclose($file);
	}
is what i'm doing wrong?

 

 

try to use lower-case hook-name, for my examples it works:

 

function hookactionProductDelete($params){
 

I've the same Problem. Someone an good idea to solve this ?

Have Anyone a good Solution ?

 

Best Regards,

Timo

Link to comment
Share on other sites

  • 1 year later...
  • 7 months later...

Thank you for your answer, but what am I looking for is a user friendly back office solution, where administrator of the shop is informed about action results.

 

After more Prestashop source code digging, I found I can use in my hook functions like

$this->context->controller->errors[];
or

 

$this->$this->adminDisplayWarning($msg);
which is great, but in my case, after updating order status, there is performed a redirect, and as PHP is stateless, all messages are lost.

 

I was thinking about storing messages to session or cookie and then retrieving them on each page load, where messages are displayed to user and then removed from session/cookie.

 

Has Prestashop similar advanced message capabilities or I have to develop my own?

 

Thank you.

 

 

Same problem here .... have you found a solution?

Thanks

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

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