From 00f95a9f2b8c206bd66e16d65506b1e13fd09984 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Wed, 1 Sep 2021 12:19:32 +0200 Subject: [PATCH] bugfix new articles --- public_html/qubeshop/lib/modules/Articles.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/public_html/qubeshop/lib/modules/Articles.php b/public_html/qubeshop/lib/modules/Articles.php index 2a7bef5..6f52013 100644 --- a/public_html/qubeshop/lib/modules/Articles.php +++ b/public_html/qubeshop/lib/modules/Articles.php @@ -48,14 +48,12 @@ class Articles{ public function getNewArticleGroups($lang){ if (!$lang){ $lang=$this->cfg["lang"];} $datescount=10; - $sql = "select ag.id, UPPER(ag.article) as article, - ag.gp_art, ag.famille_art, + $sql = "select ag.id, UPPER(ag.article) as article, ag.gp_art, ag.famille_art, coalesce(ag.titre_".$this->cfg["lang"].", ag.titre_".$this->cfg["lang"].") as titre, coalesce(ag.description_".$this->cfg["lang"].", ag.description_".$this->cfg["lang"].") as description, - ag.c01_label, ag.c02_label, ag.c03_label, ag.c03_label, ag.c04_label, ag.c05_label, - replace(ag.image, ' ', '%20') as image, + ag.c01_label, ag.c02_label, ag.c03_label, ag.c03_label, ag.c04_label, ag.c05_label, replace(ag.image, ' ', '%20') as image, ag.fichetechnique, ag.brochure, ag.noticemontage, ag.videolink, ad.creationdate - from article_groups ag join ( select article_group,creationdate from articles where isactive=1 group by article_group order by creationdate DESC LIMIT ".$datescount." ) ad on (UPPER(ag.article) = UPPER(ad.article_group)) where ag.isactive = 1 order by ad.creationdate DESC, ag.article;"; + from article_groups ag join ( select article as article_group,creationdate from ( select ag2.article,ar2.creationdate as creationdate from articles ar2 join article_groups ag2 on (ar2.article_group=ag2.article) where ag2.isactive= 1 order by ar2.creationdate DESC) ar3 group by article,creationdate order by creationdate DESC LIMIT ".$datescount." ) ad on (UPPER(ag.article) = UPPER(ad.article_group)) where ag.isactive = 1 order by ad.creationdate DESC, ag.article;"; return $this->dbh->queryarray($sql); } @@ -63,7 +61,7 @@ class Articles{ if (!$lang){ $lang=$this->cfg["lang"];} $datescount=10; //all articles returned grouped by article_group; - return $this->dbh->querybykey('article_group',"select ar.id, UPPER(ar.article_group) as article_group, UPPER(ar.article) as article, ar.gp_art, ar.famille_art, ar.c01, ar.c02, ar.c03, ar.c04, ar.c05, ap.prix_net, ar.unite_quantite, ar.qte_stock, qte_commandee, ar.doc_ft, ar.doc_mo, ar.doc_fs, ar.videolink,case when ar.creationdate + INTERVAL 1 month > CURRENT_DATE then 1 else null end as isnew from articles ar left join article_prices ap on (ar.article = ap.article) join ( select article_group, creationdate from articles where isactive = 1 group by article_group order by creationdate DESC LIMIT ".$datescount.") ag on (ar.article_group = ag.article_group) where ar.isactive = 1 group by ar.id, ar.article_group, ar.article order by ar.article_group, ar.article;"); + return $this->dbh->querybykey('article_group',"select ar.id, UPPER(ar.article_group) as article_group, UPPER(ar.article) as article, ar.gp_art, ar.famille_art, ar.c01, ar.c02, ar.c03, ar.c04, ar.c05, ap.prix_net, ar.unite_quantite, ar.qte_stock, qte_commandee, ar.doc_ft, ar.doc_mo, ar.doc_fs, ar.videolink,case when ar.creationdate + INTERVAL 1 month > CURRENT_DATE then 1 else null end as isnew from articles ar left join article_prices ap on (ar.article = ap.article) join ( select article as article_group,creationdate from ( select ag2.article,ar2.creationdate as creationdate from articles ar2 join article_groups ag2 on (ar2.article_group=ag2.article) where ag2.isactive= 1 order by ar2.creationdate DESC) ar3 group by article,creationdate order by creationdate DESC LIMIT ".$datescount.") ag on (ar.article_group = ag.article_group) where ar.isactive = 1 group by ar.id, ar.article_group, ar.article order by ar.article_group, ar.article;"); } -- 2.39.5