Jump to content

Hook for modify object


gonandriy
 Share

Recommended Posts

How you see into idea add hooks for add/update/delete object?
They may be called in postProcess method of AdminTab.
It may be usefull for developers, because help simply add new functional.
Params of hook handler may be instance of object (returned by loadObject method).

May create different hook for different kind of events (add/update/move/delete etc.) or one hook and pass type of modification into handler as parameter.

Share this post


Link to post
Share on other sites

  • 1 month later...

+1 for me
i want to add a modifyobject hook handler

Do i just need to add my hook in presta db, or do i need something else

thanks a lot

i didn't find any documentation for hooks handler

thanks a lot

pldtm

Share this post


Link to post
Share on other sites

It's not enough add your hook in presta DB. You also need add piece of code, which run this hook in prestashop core files

In general some chages can be doing in AdminTab->postProcess(). But in particular cases (picture upload), can be need something else.

Share this post


Link to post
Share on other sites

i tried to find for "adminorders.php" the "cancelproduct" hook for example
i didn't find any reference to "cancelproduct" in postprocess.
Just data in ps_hook hook_id 39.

And i can't find what's inside this hook. It could help me understand how it works

Share this post


Link to post
Share on other sites

Is hook_id 39 your own created hook?
What you mean about inside of hook? after hook run by call

Module::hookExec($hook_name, $hookArgs = array(), $id_module = NULL)


will be executed all modules, registered in this hook (with name $hook_name)
In your case seems you need add call of Module::hookExec() in AdminOrder::postProcess(), somewhere after

/* Cancel product from order */
elseif (Tools::isSubmit('cancelProduct') AND Validate::isLoadedObject($order = new Order(intval(Tools::getValue('id_order')))))



and every modules, registered in this hook will be executed.
Also I recommend you carefuly investigate code of

Module::hookExec()

method. This help you understand some things inside.

if you have any more questions, you can write me private message or over ICQ.

Share this post


Link to post
Share on other sites

So there is any way to add a new hook with a module? i create few extra hooks in db and that, also i assing at Frontcontroller.php like 'HOOK_EXTRA1' => Module::hookExec('extra1'), i don't like this way because tomorrow or something a new frontcontroller.php will be release by prestashop and that is a mess!

Regards

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
 Share

×
×
  • Create New...

Important Information

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