public function actionIndex($key)
 {
     if ($key != 'df9abe56a3487ba17d53dabf6b1abd9e') {
         throw new CHttpException(404, "Not faund");
     }
     $db = Yii::app()->db;
     $readableFile = Yii::getPathOfAlias('webroot') . $this->module->folderFiles;
     $content = @file_get_contents($readableFile . '/' . $this->module->readFileProducts);
     $errors = [];
     $productId = [];
     echo '<pre>';
     if ($content) {
         foreach (explode("\n", $content) as $id => $string) {
             // разбитие по строке
             $record = new DataRecording();
             $record->db = $db;
             $record->startLine(++$id, $string);
             if (!empty($record->errors)) {
                 print_r($record->errors);
             } else {
                 $productId[] = $record->productId;
             }
         }
         $criteria = new CDbCriteria();
         $criteria->addCondition('status = :status');
         $criteria->params = [':status' => 1];
         $criteria->addNotInCondition('id', $productId);
         $model = Product::model()->findAll($criteria);
         foreach ($model as $key => $value) {
             $value->status = 2;
             $value->save();
         }
     }
     // $this->render('index');
 }
 public function actionStart()
 {
     set_time_limit(10000);
     header("Content-Type: text/event-stream");
     header("Content-Encoding: none; ");
     header("Cache-Control: no-cache");
     header("Access-Control-Allow-Origin: *");
     ob_start();
     echo ":" . str_repeat(" ", 2048) . "\n";
     // 2 kB padding for IE
     echo "retry: 2000\n";
     //-----------------------------
     $readableFile = Yii::getPathOfAlias('webroot') . $this->module->folderFiles;
     $content = @file_get_contents($readableFile . '/' . $this->module->readFileProducts);
     if ($content) {
         foreach (explode("\n", $content) as $id => $string) {
             $array = explode(';', $string);
             $record = new DataRecording();
             $record->startLine(++$id, $string);
             $this->message($id, $record);
         }
     }
 }