<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;
class ProductController extends Controller{
public function productInfo(){
$info = D('product')->where('goods_id='.I('goods_id'))->find();
$comment_count = D('comment')->where(['goods_id'=>I('goods_id')])->count();
$comment = D('comment')->where(['goods_id'=>I('goods_id')])->select();
$product_img = D('product_images')->where('goods_id='.I('goods_id'))->select();
$this->assign('comment_count',$comment_count);
$this->assign('comment',$comment);
$this->assign('productinfo',$info);
$this->assign('product_img',$product_img);
$this->display();
}
public function productList(){
$cat_id = I('cat_id');
$sort = I('sort');
$cat_egory = D('product_category')->where(['id'=>$cat_id])->find();
if($cat_egory['parent_id'] == 0){
D('product_category')->where(['parent_id'=>0])->select();
}
$condition = "1=1";
$count = D('product')->where(['cat_id'=>$cat_id])->order($condition)->count();
$page = new Page($count,20);
$show = $page->show();
$product = D('product')
->where(['cat_id'=>$cat_id,$condition])
->order($condition)
->limit($page->firstRow.','.$page->listRows)
->select();
$this->assign('product',$product);
$this->assign('page',$show);
$this->assign('brand',$brand);
$this->assign('spec',$spec);
$this->assign('specinfo',$spec_item);
$this->display();
}
}