diff --git a/classes/Product.php b/classes/Product.php index 7b0c5c0d3..9350bc286 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1079,12 +1079,12 @@ class ProductCore extends ObjectModel $obj->available_date = '0000-00-00'; } - $obj->default_on = $default_on; - $default_on = 0; - foreach ($combination as $field => $value) $obj->$field = $value; + $obj->default_on = $default_on; + $default_on = 0; + $obj->save(); if (!$id_combination) diff --git a/controllers/admin/AdminAttributeGeneratorController.php b/controllers/admin/AdminAttributeGeneratorController.php index a394a64ee..dbbab06e5 100644 --- a/controllers/admin/AdminAttributeGeneratorController.php +++ b/controllers/admin/AdminAttributeGeneratorController.php @@ -46,7 +46,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController foreach ($attributes as $attribute) { $price += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute))); - $weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact'.(int)$attribute))); + $weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute))); } if ($this->product->id) { @@ -165,11 +165,11 @@ class AdminAttributeGeneratorControllerCore extends AdminController $attributes = array(); foreach ($tab as $group) foreach ($group as $attribute) - { - $price = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute))); - $weight = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact'.(int)$attribute))); - $attributes[] = '('.(int)$id_product.', '.(int)$attribute.', '.(float)$price.', '.(float)$weight.')'; - } + { + $price = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute))); + $weight = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute))); + $attributes[] = '('.(int)$id_product.', '.(int)$attribute.', '.(float)$price.', '.(float)$weight.')'; + } return Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'attribute_impact` (`id_product`, `id_attribute`, `price`, `weight`) @@ -177,34 +177,35 @@ class AdminAttributeGeneratorControllerCore extends AdminController ON DUPLICATE KEY UPDATE `price` = VALUES(price), `weight` = VALUES(weight)'); } - protected static function getAttributesImpacts($id_product) - { - $tab = array(); - $result = Db::getInstance()->executeS( - 'SELECT ai.`id_attribute`, ai.`price`, ai.`weight` - FROM `'._DB_PREFIX_.'attribute_impact` ai - WHERE ai.`id_product` = '.(int)$id_product); - if (!$result) - return array(); - foreach ($result as $impact) - { - $tab[$impact['id_attribute']]['price'] = (float)$impact['price']; - $tab[$impact['id_attribute']]['weight'] = (float)$impact['weight']; - } - return $tab; + protected static function getAttributesImpacts($id_product) + { + $tab = array(); + $result = Db::getInstance()->executeS( + 'SELECT ai.`id_attribute`, ai.`price`, ai.`weight` + FROM `'._DB_PREFIX_.'attribute_impact` ai + WHERE ai.`id_product` = '.(int)$id_product); + + if (!$result) + return array(); + foreach ($result as $impact) + { + $tab[$impact['id_attribute']]['price'] = (float)$impact['price']; + $tab[$impact['id_attribute']]['weight'] = (float)$impact['weight']; + } + return $tab; } public function initGroupTable() { $combinations_groups = $this->product->getAttributesGroups($this->context->language->id); $attributes = array(); - $impacts = AdminAttributeGeneratorController::getAttributesImpacts($this->product->id); + $impacts = AdminAttributeGeneratorController::getAttributesImpacts($this->product->id); foreach ($combinations_groups as &$combination) { - $target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']]; + $target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']]; $target = $combination; - if (isset($impacts[$combination['id_attribute']])) - { + if (isset($impacts[$combination['id_attribute']])) + { $target['price'] = $impacts[$combination['id_attribute']]['price']; $target['weight'] = $impacts[$combination['id_attribute']]['weight']; } diff --git a/js/attributesBack.js b/js/attributesBack.js index 490e7d3b9..240c8d8bb 100644 --- a/js/attributesBack.js +++ b/js/attributesBack.js @@ -127,7 +127,7 @@ function create_attribute_row(id, id_group, name, price, weight) html += ''+name+''; html += ''+i18n_tax_exc+''; html += ''+i18n_tax_inc+''; - html += ''; + html += ''; html += ''; return html;