/** * 类型编辑 */ public function actionUpdate() { $type_id = $this->get('type_id'); if ($_POST) { $type_attributes = $this->post('Type'); $type_brand_attributes = $this->post('TypeBrand'); //商品类型主表修改 $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')); } //类型-品牌 if ($type_brand_attributes) { $TypeBrand = new TypeBrand(); $result = $TypeBrand->brand_type_update($type_id, $type_brand_attributes); if (!$result) { $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index')); } } //类型-扩展属性 $type_props_attributes = $this->post('TypeProps'); if ($type_props_attributes) { $GoodsTypePropsRelation = new GoodsTypePropsRelation(); $result = $GoodsTypePropsRelation->props_update($type_id, $type_props_attributes['props_id']); if (!$result) { $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index')); } } //类型-规格 $type_props_spec = $this->post('Spec'); if ($type_props_spec['spec_id']) { $GoodsTypeSpec = new GoodsTypeSpec(); $result = $GoodsTypeSpec->spec_update($type_id, $type_props_spec['spec_id']); if (!$result) { $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index')); } } $this->message('success', '编辑成功', $this->createUrl('index')); } $model['type_item'] = GoodsType::model()->find('type_id = :type_id', array(':type_id' => $type_id)); //品牌列表 $model['brand_list'] = Brand::model()->findAll('disabled = :disabled', array(':disabled' => 'false')); //类型-品牌 $type_brand_list = TypeBrand::model()->findAll('type_id = :type_id', array(':type_id' => $type_id)); $model['type_brand_list'] = array(); foreach ($type_brand_list as $v) { $model['type_brand_list'][] = $v['brand_id']; } //扩展属性 $GoodsTypeProps = new GoodsTypeProps(); $model['props_list'] = $GoodsTypeProps->TypeProps($type_id); //规格 $GoodsTypeSpec = new GoodsTypeSpec(); $model['spec_list'] = Specification::model()->findAll('disabled = :disabled', array(':disabled' => 'false')); $spec_list = $GoodsTypeSpec->TypeSpec($type_id); $model['spec_selected'] = array(); foreach ($spec_list as $v) { $model['spec_selected'][$v['spec_id']] = $v['spec_id']; } $this->render('update', array('model' => $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)); }