示例#1
0
 /**
  * 
  * @param type $id
  * @return type
  */
 public static function getName($id, $mode = 'name')
 {
     $good = \app\models\Goods::findOne($id);
     \app\models\GoodsT::$tabName = self::$goodTablePefix . $good->goods_type_type;
     $goodT = \app\models\GoodsT::findOne($id);
     //        $arGoodsParamsNames = self::getGoodTypeParams($good->goods_type_type);
     $goodType = \app\models\GoodsType::findOne($good->goods_type_type);
     $arGoodsParamsNames = $goodType->getGoodsParamsNames()->orderBy('sort')->all();
     $arParams = ['goodType' => $goodType->name];
     foreach ($arGoodsParamsNames as $oParam) {
         $idParamVal = $goodT->{$oParam->id};
         $oParamValue = \app\models\GoodsParams::findOne($idParamVal);
         $arParams[$oParam->id] = $oParamValue->public_value ? $oParamValue->public_value == \Yii::$app->params['emptyStringParam'] ? '' : $oParamValue->public_value : $oParamValue->value;
     }
     $tpl = $goodType->template_view;
     if ($mode == 'array') {
         return ['name' => self::fullName($arParams, $tpl), 'goodTipe' => $goodType, 'good' => $good, 'params' => $arGoodsParamsNames, 'values' => $arParams];
     }
     return self::fullName($arParams, $tpl);
 }
 /**
  * Finds the GoodsParams model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return GoodsParams the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GoodsParams::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
 public function actionRefreshRender($val)
 {
     $arRes = [];
     $arVals = explode(';', $val);
     foreach ($arVals as $val) {
         $oVal = \app\models\GoodsParams::findOne($val);
         //            print ('<pre>');print_r($oVal);print('</pre>');
         //            $oPar = $oVal->getGoodsParamsName();
         $oPar = \app\models\GoodsParamsNameSearch::findOne($oVal->goods_params_name_id);
         //            print ('<pre>');print_r($oPar);print('</pre>');exit('100');
         $arRes[$oPar->id] = ['paramId' => $oPar->id, 'paramName' => $oPar->name, 'valId' => $oVal->id, 'valValue' => $oVal->value];
     }
     print json_encode(['res' => 'ok', 'items' => $arRes]);
 }