Skip to content

Commit

Permalink
FIX Regression when deleting product
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 11, 2016
1 parent b42a261 commit 7fd75c7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion htdocs/product/class/product.class.php
Expand Up @@ -908,10 +908,26 @@ function delete($id=0)
// End call triggers
}

// Delete from product_batch on product delete
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch';
$sql.= " WHERE fk_product_stock IN (";
$sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock';
$sql.= " WHERE fk_product = ".$id.")";
dol_syslog(get_class($this).'::delete', LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result)
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}

// Delete all child tables
if (! $error)
{
$elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_batch');
$elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price');
foreach($elements as $table)
{
if (! $error)
Expand Down

0 comments on commit 7fd75c7

Please sign in to comment.