WIP
This commit is contained in:
@@ -97,6 +97,14 @@ class ProductModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT Product.* FROM `Product`
|
||||
LEFT JOIN ProductAttribute ON (ProductAttribute.product_id = Product.id)
|
||||
LEFT JOIN Producttech ON (Product.producttech_id = Producttech.id)
|
||||
LEFT JOIN ProducttechAttribute ON (ProducttechAttribute.producttech_id = Producttech.id)
|
||||
WHERE $where
|
||||
GROUP BY Product.id";
|
||||
|
||||
$res = $db->select("Product", "*", "$where ORDER BY name, producttech_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
@@ -140,6 +148,20 @@ class ProductModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("attributename", $filter)) {
|
||||
$attributename = $db->escape($filter['attributename']);
|
||||
if($attributename) {
|
||||
$where .= " AND ProductAttribute.name = '$attributename'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("attributevalue", $filter)) {
|
||||
$attributevalue = $db->escape($filter['attributevalue']);
|
||||
if($attributevalue) {
|
||||
$where .= " AND ProductAttribute.value = '$attributevalue'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user