From 1ab92388f668a17fa78eac0b1cd0acec62f4b7ac Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 23 Dec 2015 11:51:43 +0200 Subject: [PATCH] VItaliy 22.12.2015 select details --- frontend/controllers/GoodsController.php | 22 +++++++++++++++++----- frontend/views/goods/index.php | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/controllers/GoodsController.php b/frontend/controllers/GoodsController.php index 07f5114..64f36ac 100644 --- a/frontend/controllers/GoodsController.php +++ b/frontend/controllers/GoodsController.php @@ -10,6 +10,7 @@ namespace frontend\controllers; use common\components\CustomVarDamp; use common\models\DetailsCrosses; +use common\models\GoodsView; use common\models\GoodsViewSearch; use Yii; use yii\web\Controller; @@ -26,25 +27,36 @@ class GoodsController extends Controller { $brand = $arr_name[0]; $article = $arr_name[1]; -// $arr = ['GoodsViewSearch' => ['name' => $article, -// 'brand' => $brand]]; - $arr = ['GoodsViewSearch' => ['name' => '0092S40090', - 'brand' => 'BOSCH']]; + $arr_values = ['name' => $article, + 'brand' => $brand]; + $arr = ['GoodsViewSearch' => $arr_values]; + if(empty( Yii::$app->user->identity )){ + $margin_id = 1; + }else{ + $margin_id = Yii::$app->user->identity->margin_id; + } + +// $arr = ['GoodsViewSearch' => ['name' => '0092S40090', +// 'brand' => 'BOSCH']]; Yii::$app->session->setFlash('price_currency_id', 1); - Yii::$app->session->setFlash('price_margin_id', 1); + Yii::$app->session->setFlash('price_margin_id', $margin_id); $searchModel = new GoodsViewSearch(); $goods_provider = $searchModel->search($arr); $crosses_provider = $searchModel->searchCrosses($arr); + // для заголовка таблицы (карточка товара) + $detailsModel = GoodsView::findOne($arr_values); + return $this->render('index',[ 'goods_data_provider' => $goods_provider, 'crosses_data_provider' => $crosses_provider, + 'detailsModel' => $detailsModel, ]); } diff --git a/frontend/views/goods/index.php b/frontend/views/goods/index.php index 0f801a7..8cb7de5 100644 --- a/frontend/views/goods/index.php +++ b/frontend/views/goods/index.php @@ -173,7 +173,7 @@ $this->params['breadcrumbs'][] = $this->title; ?>