diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 5e396fba8db..bb6372fd5eb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1061,37 +1061,33 @@ class ProductCombinationLevel */ public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0) { + $result = array(); $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if (!empty($fk_price_level)) { $sql .= ' AND fk_price_level = '.intval($fk_price_level); } - $combination_price_levels = $this->db->getRows($sql); - - if (!is_array($combination_price_levels)) { - return -1; - } - - $result = array(); - - if (!empty($combination_price_levels)) { - // For more simple usage set level as array key - foreach ($combination_price_levels as $k => $row) { - $productCombinationLevel = new ProductCombinationLevel($this->db); - $productCombinationLevel->fetchFormObj($row); - $result[$row->fk_price_level] = $productCombinationLevel; + $res = $this->db->query($sql); + if ($res) { + if ($this->db->num_rows($res) > 0) { + while ($obj = $this->db->fetch_object($res)) { + $productCombinationLevel = new ProductCombinationLevel($this->db); + $productCombinationLevel->fetchFormObj($obj); + $result[$obj->fk_price_level] = $productCombinationLevel; + } } + } else { + return -1; } return $result; } /** - * assign vars form an stdclass like sql obj + * Assign vars form an stdclass like sql obj * * @param int $obj Object resultset * @return int <0 KO, >0 OK