/** * 品牌编辑 */ public function actionUpdate() { $brand_id = $this->get('brand_id'); if ($_POST) { $brand_attributes = $this->post('Brand'); $type_attributes = $this->post('GoodsType'); $brand_attributes['last_modify'] = time(); $result = Brand::model()->updatebypk($brand_id, $brand_attributes); if (!$result) { $Brand = new Brand(); $this->message('error', CHtml::errorSummary($Brand), $this->createUrl('index')); } if ($type_attributes) { $TypeBrand = new TypeBrand(); $result = $TypeBrand->type_brand_update($brand_id, $type_attributes); if (!$result) { $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index')); } } $this->referrer(); } $model['brand_item'] = Brand::model()->find('brand_id = :brand_id', array(':brand_id' => $brand_id)); $model['type_list'] = GoodsType::model()->findAll('disabled = :disabled', array(':disabled' => 'false')); $type_brand_list = TypeBrand::model()->findAll('brand_id = :brand_id', array(':brand_id' => $brand_id)); $model['type_brand_list'] = array(); foreach ($type_brand_list as $v) { $model['type_brand_list'][] = $v['type_id']; } $this->render('update', array('model' => $model)); }
/** * 品牌 */ 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); }
/** * 类型删除 */ public function actionDelete() { $type_id = $this->get('type_id'); //商品类型主表修改 $type_attributes['disabled'] = 'true'; $type_attributes['lastmodify'] = time(); $result = GoodsType::model()->updatebypk($type_id, $type_attributes); if (!$result) { $GoodsType = new GoodsType(); $this->message('error', CHtml::errorSummary($GoodsType), $this->createUrl('index')); } //类型-品牌 $result = TypeBrand::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id)); if (!$result) { $TypeBrand = new TypeBrand(); $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index')); } //类型-扩展属性 $result = GoodsTypePropsRelation::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id)); if (!$result) { $GoodsTypePropsRelation = new GoodsTypePropsRelation(); $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index')); } //类型-规格 $result = GoodsTypeSpec::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id)); if (!$result) { $GoodsTypeSpec = new GoodsTypeSpec(); $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index')); } $this->message('success', '删除成功', $this->createUrl('index')); }