/** * 品牌 */ public function actionOct() { $brand_id = 24; $type_brand_list = TypeBrand::model()->findAll('brand_id = :brand_id', array(':brand_id' => $brand_id)); $TypeBrand = new TypeBrand(); $type_ids = implode(',', $TypeBrand->getFindAllids($type_brand_list, 'type_id')); //类型列表 $type_list = GoodsType::model()->findAllBySql('SELECT * FROM car_b2c_goods_type WHERE type_id IN (' . $type_ids . ')'); //价格区间 $type_price_item = array(); foreach ($type_list as $v) { $price = unserialize($v->price); if (empty($price)) { continue; } $type_price_item = $price; } //商品属性值 $goods_type_props_list = GoodsTypeProps::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props WHERE type_id IN (' . $type_ids . ')'); $Goodstypeprops = new GoodsTypeProps(); $props_ids = implode(',', $Goodstypeprops->getFindAllids($goods_type_props_list, 'props_id')); //商品属性值数据 $goods_type_props_value_list = GoodsTypePropsValue::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props_value WHERE props_id IN (' . $props_ids . ')'); $goods_type_props_value_item = array(); foreach ($goods_type_props_value_list as $v) { $goods_type_props_value_item[$v->props_id][] = $v; } //规格 /*提交数据到页面*/ $data = array('type_list' => $type_list, 'goods_type_props_list' => $goods_type_props_list, 'goods_type_props_value_item' => $goods_type_props_value_item, 'type_price_item' => $type_price_item); $this->render('oct', $data); }
/** * Ajax获取扩展属性列表 */ public function actionAjaxlist() { $pageIndex = isset($_GET['page']) ? $_GET['page'] : 1; $goodTypeProps = new GoodsTypeProps(); $result = $goodTypeProps->PropsValueList($pageIndex, $this->pagesize); //分页 $pages = new CPagination($result['count']); echo $this->renderPartial('ajaxlist', array('dataProvider' => $result['item'], 'pages' => $pages, 'pageIndex' => $pageIndex - 1, 'propsValue' => $result['propsValue'])); }
/** * 根据类型获取规格、扩展属性 */ public function actionAjaxspecprops() { $type_id = $this->post('type_id'); //规格 $GoodsTypeSpec = new GoodsTypeSpec(); if ($GoodsTypeSpec->TypeSpec($type_id)) { $model['spec'] = true; } else { $model['spec'] = false; } //扩展属性 $GoodsTypeProps = new GoodsTypeProps(); if ($GoodsTypeProps->TypePropsRelation($type_id)) { $model['props'] = true; } else { $model['props'] = false; } echo json_encode($model); }
/** * 商品扩展属性 */ public function actionProps() { $goods_id = $this->get('goods_id'); $goods_row = Goods::model()->find('goods_id = :goods_id', array(':goods_id' => $goods_id)); //商品扩展属性 $GoodsTypeProps = new GoodsTypeProps(); if ($_POST) { $props_attributes = $this->post('Props'); $GoodsTypeProps = new GoodsTypeProps(); $result = $GoodsTypeProps->TypeGoodsValue($goods_id, $goods_row['type_id'], $props_attributes['props_id'], $props_attributes['props_value_id']); if ($result) { $this->message('success', '编辑成功', $this->createUrl('index')); } else { $this->message('error', '编辑失败', $this->createUrl('index')); } } $type_props = $GoodsTypeProps->TypeProps($goods_row['type_id']); $model['type_props'] = $type_props; $model['type_goods_value'] = $GoodsTypeProps->TypeGoodsValueList($goods_id, $goods_row['type_id']); $model['goods_row'] = $goods_row; $this->render('props', array('model' => $model)); }