thinkphp推荐商品

浏览:1589 发布日期:2017/03/01 分类:功能实现 关键字: thinkphp
thinkphp推荐商品,取消推荐
/*商品推荐,每个店铺推荐N个商品,超过N个提示。
*recommend,0不推荐,1推荐
* GetRecommendCount() 查询店铺推荐商品数量
* Author:周洪亮
*/
public function Recommend(){
$id=I('get.id');
$where['id']=$id;
$scid=M('goods_list')->field('scid')->where($where)->find();
$recomment_where['scid']=$scid['scid'];
$recomment_where['recommend']=1;
$count=GetRecommendCount($recomment_where);
if($count>=6){
$this->error('该店铺推荐商品超过六个,请取消其他商品推荐后在来尝试','../Index/Index');
}
$result=M('goods_list')->where($where)->setField('recommend',1);
if($result){
$this->success('修改成功','../Goods/goodsList');
}
}
GetRecommendCount:可以写在Common/function.php里边

function GetRecommendCount($recomment_where){
$count= M('goods_list')->where($recomment_where)->count();
return $count;

}
到此就结束了。

/*取消商品推荐
*Author:周洪亮
*/
public function NoRecommend(){
$id=I('get.id');
$where['id']=$id;
$result=M('goods_list')->where($where)->setField('recommend',0);
if($result){
$this->success('修改成功','../Goods/goodsList');
}
}


本文为周洪亮原创文章,转载无需和我联系,但请注明来自吐槽君:antionzhou.cn
评论( 相关
后面还有条评论,点击查看>>