Exemplo n.º 1
0
Arquivo: Api.php Projeto: kd-brinex/kd
 public static function tovar($params)
 {
     if (!isset($params['id'])) {
         return json_encode(['error' => $params]);
     }
     $tovar = new TovarSearch();
     $dp = $tovar->find_tovar_param($params);
     $ret = [];
     if ($dp->count > 0) {
         foreach ($dp->models as $model) {
             $ret['params'][$model['param_id']] = ['param_id' => $model['param_id'], 'value' => $model['value_char'], 'title' => $model['title'], 'name' => $model['pname']];
         }
         $ret['tovar']['id'] = $model['id'];
         $ret['tovar']['tip_id'] = $model['tip_id'];
         $ret['tovar']['category_id'] = $model['category_id'];
         $ret['tovar']['name'] = $model['name'];
         $ret['tovar']['description'] = $model['description'];
         $ret['tovar']['price'] = $model['price'];
         $ret['tovar']['store_id'] = $model['store_id'];
     }
     return json_encode($ret);
 }
Exemplo n.º 2
0
 public function getProduct()
 {
     return $this->hasOne(\app\modules\tovar\models\TovarSearch::className(), ['id' => 'product_id']);
 }
Exemplo n.º 3
0
 public function actionCategory()
 {
     $params = Yii::$app->request->queryParams;
     if (!isset($params['viewType'])) {
         $params['viewType'] = 1;
     }
     if ($params['viewType'] == 1) {
         $params['options'] = ['tag' => 'div', 'class' => 'col-sm-12', 'style' => 'padding:0px'];
         $params['itemOptions'] = ['tag' => 'div', 'class' => 'col-sm-3 offer-v1-item-cont'];
     }
     if ($params['viewType'] == 2) {
         $params['options'] = ['tag' => 'div', 'class' => 'col-sm-12 offer-v2-container', 'style' => 'padding:0px'];
         $params['itemOptions'] = ['tag' => 'div', 'class' => 'offer-v2-item-cont borders-lite'];
     }
     if ($params['viewType'] == 3) {
         $params['options'] = ['tag' => 'table', 'class' => 'col-xs-12 table offer-v3-table'];
         $params['itemOptions'] = ['tag' => 'tr', 'class' => 'tr-hover'];
     }
     //        var_dump($params);die;
     $searchModel = new TovarSearch();
     $dataProvider = $searchModel->category_list($params);
     return $this->render('category', ['dataProvider' => $dataProvider, 'params' => $params]);
 }