Skip to content

Commit 4087b20

Browse files
committed
Fix bug
1 parent 7adbd88 commit 4087b20

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

model/blog/category.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,18 @@ public function getTotalCategories($data = array())
121121

122122
public function getCategoryByPostId($post_id)
123123
{
124-
$categories = CorrespondancesCategoriesClass::getCategoriesListeName(
125-
(int)$post_id,
126-
(int)$this->context->cookie->id_lang,
127-
1
128-
);
129-
130-
return $categories;
124+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
125+
SELECT cl.`title`, cl.`link_rewrite`, cc.`categorie`
126+
FROM `'.bqSQL(_DB_PREFIX_.'prestablog_correspondancecategorie').'` as cc
127+
LEFT JOIN `'.bqSQL(_DB_PREFIX_).'prestablog_categorie` as c
128+
ON (cc.`categorie` = c.`id_prestablog_categorie`)
129+
LEFT JOIN `'.bqSQL(_DB_PREFIX_).'prestablog_categorie_lang` as cl
130+
ON (cc.`categorie` = cl.`id_prestablog_categorie`)
131+
WHERE cc.`news` = '.(int)$post_id.'
132+
AND cl.`id_lang` = '.(int)$this->context->cookie->id_lang.'
133+
AND c.`actif` = 1
134+
ORDER BY cl.`title`');
135+
136+
return $result;
131137
}
132138
}

resolver/blog/post.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function get($args)
3838
'image' => $post['image'],
3939
'imageLazy' => $post['imageLazy'],
4040
'rating' => null,
41-
'datePublished' => iconv(mb_detect_encoding(strftime($date_format, strtotime($post['datePublished']))), "utf-8//IGNORE", strftime($date_format, strtotime($post['datePublished']))),
41+
'datePublished' => iconv(
42+
mb_detect_encoding(strftime($date_format, strtotime($post['datePublished']))),
43+
"utf-8//IGNORE",
44+
strftime($date_format, strtotime($post['datePublished']))
45+
),
4246
'reviews' => function ($root, $args) use ($that) {
4347
return $that->load->resolver('blog/review/get', array(
4448
'parent' => $root,
@@ -119,7 +123,10 @@ public function categories($args)
119123
$result = $this->model_blog_category->getCategoryByPostId($post['id']);
120124
$categories = array();
121125
foreach ($result as $category) {
122-
$categories[] =$this->load->resolver('blog/category/get', array('id' => $category['id_prestablog_categorie']));
126+
$categories[] =$this->load->resolver(
127+
'blog/category/get',
128+
array('id' => $category['categorie'])
129+
);
123130
}
124131
return $categories;
125132
} else {

0 commit comments

Comments
 (0)