ecshop怎么让产品显示关联文章
2个回答
展开全部
获得指定分类下所有商品的关联文章
* sun04zh3-20130321
* @access public
* @param integer $cat_id
* @return array
*/
function get_category_linked_articles($cat_id)
{
$sql = 'SELECT a.article_id, a.title, a.file_url,
a.open_type, a.add_time ' .
'FROM ' . $GLOBALS['ecs']->table('goods_article') . ' AS ga, ' .
$GLOBALS['ecs']->table('article') . ' AS a, ' .
$GLOBALS['ecs']->table('goods').' AS g '.
"WHERE ga.article_id = a.article_id AND
".get_children($cat_id).
" AND a.is_open = 1 and ga.goods_id = g.goods_id " .
'ORDER BY a.add_time DESC';
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$row['url']= $row['open_type'] != 1 ?
build_uri('article', array('aid'=>$row['article_id']), $row['title'])
: trim($row['file_url']);
$row['add_time'] = local_date($GLOBALS['_CFG']['date_format'],
$row['add_time']);
* sun04zh3-20130321
* @access public
* @param integer $cat_id
* @return array
*/
function get_category_linked_articles($cat_id)
{
$sql = 'SELECT a.article_id, a.title, a.file_url,
a.open_type, a.add_time ' .
'FROM ' . $GLOBALS['ecs']->table('goods_article') . ' AS ga, ' .
$GLOBALS['ecs']->table('article') . ' AS a, ' .
$GLOBALS['ecs']->table('goods').' AS g '.
"WHERE ga.article_id = a.article_id AND
".get_children($cat_id).
" AND a.is_open = 1 and ga.goods_id = g.goods_id " .
'ORDER BY a.add_time DESC';
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$row['url']= $row['open_type'] != 1 ?
build_uri('article', array('aid'=>$row['article_id']), $row['title'])
: trim($row['file_url']);
$row['add_time'] = local_date($GLOBALS['_CFG']['date_format'],
$row['add_time']);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询