Reading list Switch to dark mode

    Global action hook with add, update and delete function in Prestashop

    Updated 8 April 2016

    If you want to perform any action Before Or After prestashop backend activities like add, update, and delete to different types of entities then you can use following hooks –

    These hooks are defined in add, update and delete function of ObjectModel class of Prestashop.

    1. For Add function – 

     

    • Action Before Activity –

    Hook::exec('actionObject'.get_class($this).'AddBefore', array('object' => $this));

    Here, get_class($this) defines your class name and array(‘object’ => $this) defines object with a particular ID of that class.

    For example, if you want to perform any action of your module BEFORE add product in prestashop catalog then you can use this hook. For this, Hook name will be ‘actionObjectProductAddBefore‘.

    Start your headless eCommerce
    now.
    Find out More

    All hooks will work similarly.

     

    • Action After Activity –

    Hook::exec('actionObject'.get_class($this).'AddAfter', array('object' => $this));

    Ex. Hook name for product – ‘actionObjectProductAddAfter

    2. For Update function –

     

    • Action Before Activity –

    Hook::exec('actionObject'.get_class($this).'UpdateBefore', array('object' => $this));

    Ex. Hook name for product – ‘actionObjectProductUpdateBefore

     

    • Action After Activity –

    Hook::exec('actionObject'.get_class($this).'UpdateAfter', array('object' => $this));

    Ex. Hook name for product – ‘actionObjectProductUpdateAfter

    3. For Delete function –

     

    • Action Before Activity –

    Hook::exec('actionObject'.get_class($this).'DeleteBefore', array('object' => $this));

    Ex. Hook name for product – ‘actionObjectProductDeleteBefore

     

    • Action After Activity –

    Hook::exec('actionObject'.get_class($this).'DeleteAfter', array('object' => $this));

    Ex. Hook name for product – ‘actionObjectProductDeleteAfter

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home