/** * 根据类型获取规格、扩展属性 */ 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 actionAjaxspecproducts() { $goods_id = $this->post('goods_id', 'int'); $spec_str = trim($this->post('spec_str'), ','); $GoodsTypeSpec = new GoodsTypeSpec(); $list = $GoodsTypeSpec->SpecValue($spec_str, $goods_id); echo json_encode($list); }
/** * 商品规格 */ public function actionSpec() { $goods_id = $this->get('goods_id'); $goods_row = Goods::model()->find('goods_id = :goods_id', array(':goods_id' => $goods_id)); if ($_POST) { $product_attributes = $this->post('Product'); $Product = new Products(); $result = $Product->createProduct($goods_id, $goods_row, $product_attributes); if ($result) { $this->message('success', '编辑成功', $this->createUrl('index')); } else { $this->message('error', '编辑失败', $this->createUrl('index')); } } //商品规格 $GoodsTypeSpec = new GoodsTypeSpec(); $items = $GoodsTypeSpec->TypeSpecValue($goods_row['type_id']); $spec_list_t = $GoodsTypeSpec->ProductSpecList($goods_id); $spec_list = array(); foreach ($spec_list_t as $v) { $spec_list[$v['spec_id']] = $v; } //货品列表 $product_list = Products::model()->findAll('goods_id = :goods_id AND spec_desc <> :spec_desc AND disabled = :disabled', array(':goods_id' => $goods_id, ':spec_desc' => '', ':disabled' => 'false')); echo $this->render('spec', array('items' => $items, 'spec_list' => $spec_list, 'goods_row' => $goods_row, 'product_list' => $product_list)); }