This commit is contained in:
Frank Schubert
2022-05-12 17:39:29 +02:00
parent ebf2f808f3
commit 117b56a301
5 changed files with 49 additions and 4 deletions

View File

@@ -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;
}