Jump to content

Trigger Hooks from Web Service Call


jorgehivis

Recommended Posts

Hi guys,

 

I was wondering whether Hooks are triggered when calling Web Services? For example, when updating a product stock level via Web Services, I want the "hookActionUpdateQuantity" to be triggered. I know this hook is triggered if you manually do it via Admin interface. Does the same trigger happens when doing it via Web Service?

 

Regards,

Jorge

Link to comment
Share on other sites

I couldn't find a reference to it, but I did find this:
 

    public function updateWs($null_values = false)
    {
        $success = parent::update($null_values);
        if ($success && Configuration::get('PS_SEARCH_INDEXATION')) {
            Search::indexation(false, $this->id);
        }
        Hook::exec('updateProduct', array('id_product' => (int)$this->id));
        return $success;
    }

so updateProduct definitely runs, at least
Link to comment
Share on other sites

Thank you for your reply.
 
Is this code part of prestashop core files? If so, where is it? If not, is it actually a suggested function to be added somewhere in presta as a solution?
 
I couldn't find it on my presta installation. I have found a similar one though:
 
classes/stock/StockAvailable.php - Line 100

public function updateWs()
{
    if ($this->depends_on_stock) {
        return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You cannot update the available stock when it depends on stock.'), 133);
    }
    return $this->update();
}
Edited by jorgehivis (see edit history)
Link to comment
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
×
×
  • Create New...