Clean code
This commit is contained in:
parent
5d4cf586d6
commit
f5edd25f6d
@ -1061,37 +1061,33 @@ class ProductCombinationLevel
|
|||||||
*/
|
*/
|
||||||
public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0)
|
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 = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
|
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination);
|
$sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination);
|
||||||
|
|
||||||
if (!empty($fk_price_level)) {
|
if (!empty($fk_price_level)) {
|
||||||
$sql .= ' AND fk_price_level = '.intval($fk_price_level);
|
$sql .= ' AND fk_price_level = '.intval($fk_price_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
$combination_price_levels = $this->db->getRows($sql);
|
$res = $this->db->query($sql);
|
||||||
|
if ($res) {
|
||||||
if (!is_array($combination_price_levels)) {
|
if ($this->db->num_rows($res) > 0) {
|
||||||
return -1;
|
while ($obj = $this->db->fetch_object($res)) {
|
||||||
}
|
|
||||||
|
|
||||||
$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 = new ProductCombinationLevel($this->db);
|
||||||
$productCombinationLevel->fetchFormObj($row);
|
$productCombinationLevel->fetchFormObj($obj);
|
||||||
$result[$row->fk_price_level] = $productCombinationLevel;
|
$result[$obj->fk_price_level] = $productCombinationLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assign vars form an stdclass like sql obj
|
* Assign vars form an stdclass like sql obj
|
||||||
*
|
*
|
||||||
* @param int $obj Object resultset
|
* @param int $obj Object resultset
|
||||||
* @return int <0 KO, >0 OK
|
* @return int <0 KO, >0 OK
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user