FIX #11446
This commit is contained in:
parent
27ba3408b4
commit
b065cbc6f8
@ -3716,7 +3716,7 @@ class Product extends CommonObject
|
|||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits
|
* Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits
|
||||||
* Define value of this->res
|
* Define value of this->res
|
||||||
*
|
*
|
||||||
* @param array $prod Products array
|
* @param array $prod Products array
|
||||||
* @param string $compl_path Directory path of parents to add before
|
* @param string $compl_path Directory path of parents to add before
|
||||||
@ -3730,7 +3730,7 @@ class Product extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$product = new Product($this->db);
|
$tmpproduct = null;
|
||||||
//var_dump($prod);
|
//var_dump($prod);
|
||||||
foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product
|
foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product
|
||||||
{
|
{
|
||||||
@ -3746,23 +3746,26 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
//print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n";
|
//print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n";
|
||||||
$this->fetch($id); // Load product
|
if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop.
|
||||||
$this->load_stock('nobatch,novirtual'); // Load stock to get true this->stock_reel
|
$tmpproduct->fetch($id); // Load product to get ->ref
|
||||||
|
$tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel
|
||||||
|
//$this->fetch($id); // Load product to get ->ref
|
||||||
|
//$this->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel
|
||||||
$this->res[]= array(
|
$this->res[]= array(
|
||||||
'id'=>$id, // Id product
|
'id'=>$id, // Id product
|
||||||
'id_parent'=>$id_parent,
|
'id_parent'=>$id_parent,
|
||||||
'ref'=>$this->ref, // Ref product
|
'ref'=>$tmpproduct->ref, // Ref product
|
||||||
'nb'=>$nb, // Nb of units that compose parent product
|
'nb'=>$nb, // Nb of units that compose parent product
|
||||||
'nb_total'=>$nb*$multiply, // Nb of units for all nb of product
|
'nb_total'=>$nb*$multiply, // Nb of units for all nb of product
|
||||||
'stock'=>$this->stock_reel, // Stock
|
'stock'=>$tmpproduct->stock_reel, // Stock
|
||||||
'stock_alert'=>$this->seuil_stock_alerte, // Stock alert
|
'stock_alert'=>$tmpproduct->seuil_stock_alerte, // Stock alert
|
||||||
'label'=>$label,
|
'label'=>$label,
|
||||||
'fullpath'=>$compl_path.$label, // Label
|
'fullpath'=>$compl_path.$label, // Label
|
||||||
'type'=>$type, // Nb of units that compose parent product
|
'type'=>$type, // Nb of units that compose parent product
|
||||||
'desiredstock'=>$this->desiredstock,
|
'desiredstock'=>$tmpproduct->desiredstock,
|
||||||
'level'=>$level,
|
'level'=>$level,
|
||||||
'incdec'=>$incdec,
|
'incdec'=>$incdec,
|
||||||
'entity'=>$this->entity
|
'entity'=>$tmpproduct->entity
|
||||||
);
|
);
|
||||||
|
|
||||||
// Recursive call if there is childs to child
|
// Recursive call if there is childs to child
|
||||||
|
|||||||
@ -45,7 +45,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
|||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||||
*/
|
*/
|
||||||
class ProductTest extends PHPUnit_Framework_TestCase
|
class ProductTest extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected $savconf;
|
protected $savconf;
|
||||||
protected $savuser;
|
protected $savuser;
|
||||||
@ -168,6 +168,31 @@ class ProductTest extends PHPUnit_Framework_TestCase
|
|||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testProductGetArboEachProd
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testProductGetArboEachProd()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
/*
|
||||||
|
$localobject=new Product($db);
|
||||||
|
$localobject->fetch(208);
|
||||||
|
$localobject->get_sousproduits_arbo();
|
||||||
|
$localobject->get_arbo_each_prod();
|
||||||
|
|
||||||
|
var_dump($localobject->res); print (json_encode($localobject->res)); exit;
|
||||||
|
*/
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testProductUpdate
|
* testProductUpdate
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user