forked from Wavyzz/dolibarr
Merge pull request #32563 from marc-dll/18.0_FIX_variants_copy_multiprices
FIX: product variants copy: also copy multiprice variations
This commit is contained in:
@@ -702,16 +702,16 @@ class ProductCombination
|
|||||||
* [...]
|
* [...]
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @param User $user Object user
|
* @param User $user Object user
|
||||||
* @param Product $product Parent product
|
* @param Product $product Parent product
|
||||||
* @param array $combinations Attribute and value combinations.
|
* @param array $combinations Attribute and value combinations.
|
||||||
* @param array $variations Price and weight variations
|
* @param array $variations Price and weight variations
|
||||||
* @param bool|array $price_var_percent Is the price variation a relative variation?
|
* @param bool|array $price_var_percent Is the price variation a relative variation?
|
||||||
* @param bool|float $forced_pricevar If the price variation is forced
|
* @param bool|float|array $forced_pricevar If the price variation is forced
|
||||||
* @param bool|float $forced_weightvar If the weight variation is forced
|
* @param bool|float $forced_weightvar If the weight variation is forced
|
||||||
* @param bool|string $forced_refvar If the reference is forced
|
* @param bool|string $forced_refvar If the reference is forced
|
||||||
* @param string $ref_ext External reference
|
* @param string $ref_ext External reference
|
||||||
* @return int <0 KO, >0 OK
|
* @return int <0 KO, >0 OK
|
||||||
*/
|
*/
|
||||||
public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '')
|
public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '')
|
||||||
{
|
{
|
||||||
@@ -752,8 +752,8 @@ class ProductCombination
|
|||||||
$price_impact = $forced_pricevar;
|
$price_impact = $forced_pricevar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array($price_var_percent)) {
|
if (!is_array($price_var_percent)) {
|
||||||
$price_var_percent[1] = (float) $price_var_percent;
|
$price_var_percent = array(1 => (bool) $price_var_percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newcomb = new ProductCombination($this->db);
|
$newcomb = new ProductCombination($this->db);
|
||||||
@@ -840,12 +840,7 @@ class ProductCombination
|
|||||||
$productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
|
$productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
|
||||||
$productCombinationLevel->fk_price_level = $i;
|
$productCombinationLevel->fk_price_level = $i;
|
||||||
$productCombinationLevel->variation_price = $price_impact[$i];
|
$productCombinationLevel->variation_price = $price_impact[$i];
|
||||||
|
$productCombinationLevel->variation_price_percentage = $price_var_percent[$i];
|
||||||
if (is_array($price_var_percent)) {
|
|
||||||
$productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]);
|
|
||||||
} else {
|
|
||||||
$productCombinationLevel->variation_price_percentage = $price_var_percent;
|
|
||||||
}
|
|
||||||
|
|
||||||
$newcomb->combination_price_levels[$i] = $productCombinationLevel;
|
$newcomb->combination_price_levels[$i] = $productCombinationLevel;
|
||||||
}
|
}
|
||||||
@@ -955,13 +950,26 @@ class ProductCombination
|
|||||||
$variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
|
$variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$variation_price_percentage = $combination->variation_price_percentage;
|
||||||
|
$variation_price = $combination->variation_price;
|
||||||
|
|
||||||
|
if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) {
|
||||||
|
$variation_price_percentage = [ ];
|
||||||
|
$variation_price = [ ];
|
||||||
|
|
||||||
|
foreach ($combination->combination_price_levels as $productCombinationLevel) {
|
||||||
|
$variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage;
|
||||||
|
$variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->createProductCombination(
|
if ($this->createProductCombination(
|
||||||
$user,
|
$user,
|
||||||
$destProduct,
|
$destProduct,
|
||||||
$variations,
|
$variations,
|
||||||
array(),
|
array(),
|
||||||
$combination->variation_price_percentage,
|
$variation_price_percentage,
|
||||||
$combination->variation_price,
|
$variation_price,
|
||||||
$combination->variation_weight
|
$combination->variation_weight
|
||||||
) < 0) {
|
) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user