diff --git a/controllers/EventController.php b/controllers/EventController.php index 387bb36..30a5126 100755 --- a/controllers/EventController.php +++ b/controllers/EventController.php @@ -113,6 +113,7 @@ class EventController extends Controller if ( ($file = UploadedFile::getInstance($model, 'products_file')) ) { if(!empty($file)){ + $file->saveAs(Yii::getAlias('@uploadDir/' . $file->name)); $model->goEvent(Yii::getAlias('@uploadDir/' . $file->name)); } diff --git a/models/Event.php b/models/Event.php index c7f1abc..24da4e9 100755 --- a/models/Event.php +++ b/models/Event.php @@ -170,13 +170,13 @@ class Event extends \yii\db\ActiveRecord while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { - if(isset($data[0]) && isset($data[1])){ - $product = ProductVariant::find()->where(['sku' => $data[1]])->joinWith('product')->one(); + if(isset($data[0])){ + $product = ProductVariant::find()->where(['sku' => $data[0]])->joinWith('product')->one(); if($product instanceof ProductVariant){ - $model= EventsToProducts::find()->where(['event_id' =>$data[0], 'product_id' => $product->product->id ])->one(); + $model= EventsToProducts::find()->where(['event_id' =>$this->id, 'product_id' => $product->product->id ])->one(); if(!$model instanceof EventsToProducts){ $model = new EventsToProducts; - $model->event_id = $data[0]; + $model->event_id = $this->id; $model->product_id = $product->product->id; $model->save(); } @@ -190,7 +190,7 @@ class Event extends \yii\db\ActiveRecord } public function getProducts(){ - return $this->hasMany(Product::className(),['product_id' => 'product_id'] )->viaTable('events_to_products', ['id' => 'event_id']); + return $this->hasMany(Product::className(),['id' => 'product_id'] )->viaTable('events_to_products', ['event_id' => 'id']); } public static function getSaleEvents(){ diff --git a/views/event/index.php b/views/event/index.php index e5962b0..c575d9d 100755 --- a/views/event/index.php +++ b/views/event/index.php @@ -25,10 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - - 'id', - 'lang.title', - 'lang.alias', + 'lang.title:ntext', 'imageUrl:image', // 'meta_title', // 'description', -- libgit2 0.21.4