getConnection(); // Recupera i prodotti con le variazioni e le classi associate $stmt = $pdo->prepare(" SELECT p.id, p.name AS product_name, MIN(pv.price) AS min_price, MAX(pv.price) AS max_price, c.name AS class_name, c.image AS class_image FROM products p LEFT JOIN product_variations pv ON p.id = pv.product_id LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL LEFT JOIN class_types ct ON pct.class_type_id = ct.id LEFT JOIN classes c ON ct.class_id = c.id WHERE p.status = 'active' GROUP BY p.id "); $stmt->execute(); $products = $stmt->fetchAll(PDO::FETCH_ASSOC); ?>