From e9e3de8ba5e5ce0841ad1e0f9815cec8bc21597e Mon Sep 17 00:00:00 2001 From: Garraro Date: Thu, 12 Nov 2020 17:36:31 -0300 Subject: [PATCH] correciones probando pedir datos de la web --- config/api.php | 11 +++++++++-- controllers/front/carts.php | 4 ++-- controllers/front/categories.php | 4 ++-- controllers/front/combinations.php | 4 ++-- controllers/front/customers.php | 4 ++-- controllers/front/images.php | 2 +- controllers/front/products.php | 4 ++-- controllers/front/promos.php | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/config/api.php b/config/api.php index e054592..4f85a20 100644 --- a/config/api.php +++ b/config/api.php @@ -50,7 +50,7 @@ 'with' => [ 'products' => [ 'selectClause' => 'GROUP_CONCAT(cp.id_product) AS id_products', - 'fromClause' => 'INNER JOIN ps_category_product cp ON cp.id_category = c.id_category', + 'fromClause' => 'LEFT JOIN ps_category_product cp ON cp.id_category = c.id_category', 'whereClause' => '', 'groupClause' => '', 'orderClause' => '' @@ -61,7 +61,14 @@ 'whereClause' => '', 'groupClause' => '', 'orderClause' => '' - ] + ], + 'childs' => [ + 'selectClause' => ' GROUP_CONCAT(distinct ch.id_category) AS id_child', + 'fromClause' => 'left join ps_category ch on ch.id_parent = c.id_category', + 'whereClause' => '', + 'groupClause' => '', + 'orderClause' => '' + ] ] ], 'customers' => [ diff --git a/controllers/front/carts.php b/controllers/front/carts.php index bae00b5..1daa265 100644 --- a/controllers/front/carts.php +++ b/controllers/front/carts.php @@ -35,9 +35,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } } diff --git a/controllers/front/categories.php b/controllers/front/categories.php index acb9023..bccb9df 100644 --- a/controllers/front/categories.php +++ b/controllers/front/categories.php @@ -34,9 +34,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } } diff --git a/controllers/front/combinations.php b/controllers/front/combinations.php index ea40eb4..f40569d 100644 --- a/controllers/front/combinations.php +++ b/controllers/front/combinations.php @@ -35,9 +35,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } } diff --git a/controllers/front/customers.php b/controllers/front/customers.php index 21c896f..e5376d1 100644 --- a/controllers/front/customers.php +++ b/controllers/front/customers.php @@ -35,9 +35,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } } diff --git a/controllers/front/images.php b/controllers/front/images.php index 18eefe4..5370f09 100644 --- a/controllers/front/images.php +++ b/controllers/front/images.php @@ -38,6 +38,6 @@ public function initContent() // print_r (Db::getInstance()->getRow($sql)); // } else { // } - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } diff --git a/controllers/front/products.php b/controllers/front/products.php index 5463f14..c40b0ed 100644 --- a/controllers/front/products.php +++ b/controllers/front/products.php @@ -35,9 +35,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } } diff --git a/controllers/front/promos.php b/controllers/front/promos.php index 5e58cf9..2ad3da3 100644 --- a/controllers/front/promos.php +++ b/controllers/front/promos.php @@ -35,9 +35,9 @@ public function initContent() $sql = $query->toString(); if ($id != null){ - print_r (Db::getInstance()->getRow($sql)); + echo (json_encode(Db::getInstance()->getRow($sql))); } else { - print_r (Db::getInstance()->executeS($sql)); + echo (json_encode(Db::getInstance()->executeS($sql))); } } }