NEW: add a $notrigger param to Product::updatePrice() method (#26404)

* NEW: add a $notrigger param to Product::updatePrice() method

* Update product.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
jyhere 2023-10-31 06:57:25 -04:00 committed by GitHub
parent 4c8870f205
commit d2355e91e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2209,9 +2209,10 @@ class Product extends CommonObject
* @param int $ignore_autogen Used to avoid infinite loops
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param string $newdefaultvatcode Default vat code
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '')
public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $notrigger = 0)
{
global $conf, $langs;
@ -2380,10 +2381,12 @@ class Product extends CommonObject
$this->level = $level; // Store level of price edited for trigger
// Call trigger
$result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
if (!$notrigger) {
$result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
}
}
// End call triggers
@ -5825,8 +5828,8 @@ class Product extends CommonObject
$reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
if ($reshook > 0) {
$this->stock_theorique = $hookmanager->resArray['stock_theorique'];
} elseif (isset($hookmanager->resArray['stock_stats_hook'])) {
$this->stock_theorique += $hookmanager->resArray['stock_stats_hook'];
} elseif ($reshook == 0 && isset($hookmanager->resArray['stock_stats_hook'])) {
$this->stock_theorique += $hookmanager->resArray['stock_stats_hook'];
}
return 1;