调用指定分类的商品点击排行榜

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家


  1. /**
  2. * 调用当前分类的商品点击排行榜 liangfang add
  3. *
  4. * @accesspublic
  5. * @paramstring$cats查询的分类
  6. * @returnarray
  7. */
  8. function get_onclick_top($cats = '')
  9. {
  10. $cats = get_children($cats);
  11. $where = !empty($cats) ? "AND ($cats OR " . get_extension_goods($cats) . ") " : '';
  12. $sql = 'SELECT g.goods_id, g.goods_name, g.shop_price, g.goods_thumb,g.click_count ' .
  13. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  14. "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 $where ".
  15. 'ORDER BY g.click_count DESC LIMIT ' . $GLOBALS['_CFG']['top_number'];
  16. //echo $sql;
  17. $arr = $GLOBALS['db']->getAll($sql);
  18. for ($i = 0, $count = count($arr); $i < $count; $i++)
  19. {
  20. $arr[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
  21. sub_str($arr[$i]['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $arr[$i]['goods_name'];
  22. $arr[$i]['url']= build_uri('goods', array('gid' => $arr[$i]['goods_id']), $arr[$i]['goods_name']);
  23. $arr[$i]['thumb'] = get_image_path($arr[$i]['goods_id'], $arr[$i]['goods_thumb'],true);
  24. $arr[$i]['price'] = price_format($arr[$i]['shop_price']);
  25. $arr[$i]['click_count'] = $arr[$i]['click_count'];
  26. }

  27. return $arr;

  28. }
复制代码

回答:
不错的样子哦