Merge pull request #13951 from Langlais115/keep_child_label_if_modified

FIX #13908 keep child label if modified by user
This commit is contained in:
Laurent Destailleur 2020-05-23 13:51:29 +02:00 committed by GitHub
commit 0db549469c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,14 +326,20 @@ class ProductCombination
$child = new Product($this->db);
$child->fetch($this->fk_product_child);
$child->price_autogen = $parent->price_autogen;
$child->price_autogen = $parent->price_autogen;
$child->weight = $parent->weight;
if ($this->variation_weight) { // If we must add a delta on weight
$child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight;
}
$child->weight_units = $parent->weight_units;
$varlabel = $this->getCombinationLabel($this->fk_product_child);
$child->label = $parent->label.$varlabel;
$child->weight_units = $parent->weight_units;
// Don't update the child label if the user has already modified it.
if ($child->label == $parent->label) {
// This will trigger only at variant creation time
$varlabel = $this->getCombinationLabel($this->fk_product_child);
$child->label = $parent->label.$varlabel;;
}
if ($child->update($child->id, $user) > 0) {
$new_vat = $parent->tva_tx;