Commit b53ca4c1 authored by Philippe Pary's avatar Philippe Pary
Browse files

fixed bug in product display

parent 228b18f1
......@@ -50,8 +50,7 @@ class ProductsService {
$sql = NULL;
if ($include_hidden) {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE DELETED = " . $db->false();
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID ";
} else {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT AND DELETED = "
......@@ -68,8 +67,7 @@ class ProductsService {
$sql = NULL;
if ($include_hidden) {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE DELETED = " . $db->false();
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID ";
} else {
$sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT AND DELETED = "
......@@ -110,18 +108,17 @@ class ProductsService {
$db = DB::get();
$sql = NULL;
if ($include_hidden) {
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM CATEGORIES, PRODUCTS "
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM PRODUCTS "
. "LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE 1=1";
} else {
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM CATEGORIES, PRODUCTS "
$sql = "SELECT PRODUCTS.*, PRODUCTS_CAT.* FROM PRODUCTS "
. "LEFT JOIN PRODUCTS_CAT ON "
. "PRODUCTS_CAT.PRODUCT = PRODUCTS.ID "
. "WHERE DELETED = " . $db->false();
}
$sql .= " AND PRODUCTS.CATEGORY = CATEGORIES.ID ";
$sql .= " ORDER BY DELETED ASC, CATEGORIES.DISPORDER, CATEGORY, CATORDER, PRODUCTS.NAME";
$sql .= " ORDER BY CATORDER, NAME";
$sql .= " LIMIT ".$range." OFFSET ".$start;
$stmt = $pdo->prepare($sql);
$stmt->execute();
......@@ -179,8 +176,8 @@ class ProductsService {
$pdo = PDOBuilder::getPDO();
$db = DB::get();
$stmt = $pdo->prepare("SELECT * FROM PRODUCTS, PRODUCTS_CAT WHERE "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT AND DELETED = "
. $db->false() . " AND PRODUCTS.CATEGORY = :cat "
. "PRODUCTS.ID = PRODUCTS_CAT.PRODUCT "
. "AND PRODUCTS.CATEGORY = :cat "
. "ORDER BY CATORDER, NAME");
$stmt->bindParam(":cat", $categoryId, \PDO::PARAM_STR);
if ($stmt->execute()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment