Fix and factor fetch combination price level
This commit is contained in:
parent
e4557b3dd3
commit
cd952f7427
@ -165,18 +165,12 @@ class ProductCombination
|
|||||||
/**
|
/**
|
||||||
* for auto retrocompatibility with last behavior
|
* for auto retrocompatibility with last behavior
|
||||||
*/
|
*/
|
||||||
$productCombinationLevel = new ProductCombinationLevel($this->db);
|
|
||||||
$productCombinationLevel->fk_price_level = intval($fk_price_level);
|
|
||||||
$productCombinationLevel->fk_product_attribute_combination = $this->id;
|
|
||||||
$productCombinationLevel->variation_price = $this->variation_price;
|
|
||||||
$productCombinationLevel->variation_price_percentage = $this->variation_price_percentage;
|
|
||||||
|
|
||||||
if ($fk_price_level>0){
|
if ($fk_price_level>0){
|
||||||
$combination_price_levels[$fk_price_level] = $productCombinationLevel;
|
$combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){
|
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){
|
||||||
$combination_price_levels[$i] = $productCombinationLevel;
|
$combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1211,4 +1205,25 @@ class ProductCombinationLevel
|
|||||||
|
|
||||||
return $res ? 1 : -1;
|
return $res ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new Product Combination Price level from Parent
|
||||||
|
*
|
||||||
|
* @param DoliDB $db
|
||||||
|
* @param ProductCombination $productCombination
|
||||||
|
* @param int $fkPriceLevel
|
||||||
|
*
|
||||||
|
* @return ProductCombinationLevel
|
||||||
|
*/
|
||||||
|
public static function createFromParent(DoliDB $db, ProductCombination $productCombination, $fkPriceLevel)
|
||||||
|
{
|
||||||
|
$productCombinationLevel = new self($db);
|
||||||
|
$productCombinationLevel->fk_price_level = $fkPriceLevel;
|
||||||
|
$productCombinationLevel->fk_product_attribute_combination = $productCombination->id;
|
||||||
|
$productCombinationLevel->variation_price = $productCombination->variation_price;
|
||||||
|
$productCombinationLevel->variation_price_percentage = $productCombination->variation_price_percentage;
|
||||||
|
|
||||||
|
return $productCombinationLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user