Пример #1
0
 /**
  * Ajax获取商品列表
  */
 public function actionAjaxgoodslist()
 {
     $pageIndex = isset($_GET['page']) ? $_GET['page'] : 1;
     $params = $this->get('Goods');
     $Goods = new Goods();
     //改为用produnct表中 product_id 查询
     if (!empty($params['bn'])) {
         $sql = "select g.bn from car_b2c_products as p left join car_b2c_goods as g on g.goods_id = p.goods_id where p.product_id = '" . $params['bn'] . "'";
         $res = $Goods->queryRow($sql);
         if (!empty($res)) {
             $params['bn'] = $res['bn'];
         }
     }
     $result = $Goods->items(GoodsFilter::goods($params), $pageIndex, $this->pagesize);
     $items = $result['items'];
     $count = $result['count'];
     //分页
     $pages = new CPagination($count);
     echo $this->renderPartial('ajaxgoodslist', array('dataProvider' => $items, 'pages' => $pages, 'pageIndex' => $pageIndex - 1, 'params' => $params));
 }