/** * 获得商品属性 */ function get_product_attr() { //产品信息 $model = M('Product'); $data['id'] = $_POST['product_id']; $vo = $model->field('id,lit_pic,product_type')->where($data)->find(); //产品属性 $ga_model = M('Product_attr'); $ga_data['product_id'] = $_POST['product_id']; $goods_attrs = $ga_model->where($ga_data)->select(); //组装属性数组 foreach ($goods_attrs as $attrs) { $key = $attrs['attr_id']; $attr_vals[$key][] = $attrs; } $cat_id = $_POST['tid']; //$this->attr_assign($cat_id,$attr_vals); $attrs = get_attr_assign($cat_id, $attr_vals); $this->assign('attrs', $attrs); $this->display(); }
/** +---------------------------------------------------------- * 属性处理 +---------------------------------------------------------- * $cat_id 分类ID +---------------------------------------------------------- * $attr_vals 商品属性值 +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ function attr_assign($cat_id, $attr_vals) { $attrs = get_attr_assign(); $this->assign('attrs', $attrs); }