Merge pull request #21534 from defrance/patch-216

Some Fix on Variant module
This commit is contained in:
Laurent Destailleur 2022-07-24 20:15:56 +02:00 committed by GitHub
commit 44ae25b4cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -281,7 +281,9 @@ class ProductCombination
{
global $conf;
$sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".((int) $fk_product_parent)." AND entity IN (".getEntity('product').")";
$sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_ref_ext, variation_weight";
$sql.= " FROM ".MAIN_DB_PREFIX."product_attribute_combination";
$sql.= " WHERE fk_product_parent = ".((int) $fk_product_parent)." AND entity IN (".getEntity('product').")";
$query = $this->db->query($sql);
@ -489,10 +491,10 @@ class ProductCombination
$child->price_autogen = $parent->price_autogen;
$child->weight = $parent->weight;
// Only when Parent Status are updated
if ($parent->oldcopy && ($parent->status != $parent->oldcopy->status)) {
if (!empty($parent->oldcopy) && ($parent->status != $parent->oldcopy->status)) {
$child->status = $parent->status;
}
if ($parent->oldcopy && ($parent->status_buy != $parent->oldcopy->status_buy)) {
if (!empty($parent->oldcopy) && ($parent->status_buy != $parent->oldcopy->status_buy)) {
$child->status_buy = $parent->status_buy;
}

View File

@ -69,7 +69,7 @@ if ($id > 0 || $ref) {
$object->fetch($id, $ref);
}
$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : 0;
$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : array();
// Security check
if (empty($conf->variants->enabled)) {
@ -154,7 +154,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$price_impact = price2num($price_impact);
// for conf PRODUIT_MULTIPRICES
if ($conf->global->PRODUIT_MULTIPRICES) {
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
$level_price_impact = array_map('price2num', $level_price_impact);
} else {
$level_price_impact = array(1 => $price_impact);
@ -279,7 +279,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$prodcomb->variation_weight = price2num($weight_impact);
// for conf PRODUIT_MULTIPRICES
if ($conf->global->PRODUIT_MULTIPRICES) {
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
$level_price_impact = array_map('price2num', $level_price_impact);
$prodcomb->variation_price = $level_price_impact[1];
@ -292,7 +292,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$prodcomb->variation_price_percentage = $price_impact_percent;
}
if ($conf->global->PRODUIT_MULTIPRICES) {
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
$prodcomb->combination_price_levels = array();
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$productCombinationLevel = new ProductCombinationLevel($db);