From 4ca71a5540b55abf7eac4a16a246ce55e5bf5168 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 15 Dec 2016 23:45:33 +0200 Subject: [PATCH] Ntr --- common/models/Event.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/models/Event.php b/common/models/Event.php index dab6210..4624041 100755 --- a/common/models/Event.php +++ b/common/models/Event.php @@ -146,14 +146,17 @@ class Event extends \yii\db\ActiveRecord $handle = fopen($file, 'r'); - EventsToProducts::deleteAll(['event_id' =>iconv('cp1251', 'utf-8', $this->event_id)]); + EventsToProducts::deleteAll(['event_id' =>$this->event_id]); while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { if(isset($data[0]) && isset($data[1])){ $product = ProductVariant::find()->where(['sku' => iconv('cp1251', 'utf-8', $data[1])])->joinWith('product')->one(); - $model = new EventsToProducts; - $model->event_id = iconv('cp1251', 'utf-8', $data[0]); - $model->product_id = $product->product->product_id; - $model->save(); + if($product instanceof ProductVariant){ + $model = new EventsToProducts; + $model->event_id = $this->event_id; + $model->product_id = $product->product->product_id; + $model->save(); + } + } -- libgit2 0.21.4