public static function getPostCategories($post_id, $checkContext = true, $active = true) { if ($checkContext) { $context = Context::getContext(); $id_lang = $context->language->id; } $query = 'SELECT pc.`id_blog_category`, c.`name`, c.`link_rewrite`, c.`id_lang` FROM ' . _DB_PREFIX_ . 'blog_categories pc INNER JOIN ' . _DB_PREFIX_ . 'blog_category c ON c.`id_blog_category` = pc.`id_blog_category` '; if ($checkContext) { $query .= BlogShop::addShopAssociation('blog_category', 'c'); } $query .= ' WHERE pc.`id_blog_post` = ' . (int) $post_id; if ($checkContext) { $query .= ' AND (c.id_lang = ' . intval($id_lang) . ' OR c.id_lang = 0) '; } if ($active) { $query .= ' AND c.`active` = 1'; } $query .= ' GROUP BY c.`id_blog_category` ORDER BY c.`position` ASC, c.`name` ASC'; $result = Db::getInstance()->ExecuteS($query); return $result; }
public function listRelated($checkContext = true, $publish = true) { if ($checkContext) { $context = Context::getContext(); $id_lang = $context->language->id; } $query = 'SELECT p.`id_blog_post`, p.`title`, p.`link_rewrite`, p.`id_lang` FROM ' . _DB_PREFIX_ . 'blog_related pr INNER JOIN ' . _DB_PREFIX_ . 'blog_post p ON p.`id_blog_post` = pr.`id_related_blog_post`'; if ($checkContext) { $query .= BlogShop::addShopAssociation('blog_post', 'p'); } $query .= ' WHERE pr.`id_blog_post` = ' . intval($this->id); if ($checkContext) { $query .= ' AND (p.id_lang = ' . intval($id_lang) . ' OR p.id_lang = 0) '; } if ($publish) { $query .= ' AND p.`status` = "published" AND p.`date_on` <= NOW()'; } $query .= ' ORDER BY p.`date_on` DESC, p.`id_blog_post` DESC'; return Db::getInstance()->ExecuteS($query); }