/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductSpecification::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'product_id' => $this->product_id]);
     $query->andFilterWhere(['like', 'item_name', $this->item_name])->andFilterWhere(['like', 'item_val', $this->item_val]);
     return $dataProvider;
 }
 protected function findModel($id)
 {
     if (($model = ProductSpecification::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Deletes an existing Product model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     ProductCategoryRel::deleteAll(['product_id' => $id]);
     $images = ProductImageRel::findAll(['product_id' => $id]);
     if (!empty($images)) {
         foreach ($images as $key => $value) {
             unlink(\Yii::getAlias('@webroot') . '/product_uploads/' . $value->image);
         }
     }
     ProductImageRel::deleteAll(['product_id' => $id]);
     $files = ProductFiles::findAll(['product_id' => $id]);
     if (!empty($files)) {
         foreach ($files as $key => $value) {
             unlink(\Yii::getAlias('@webroot') . '/product_files/' . $value->file_name);
         }
     }
     ProductFiles::deleteAll(['product_id' => $id]);
     ProductSpecification::deleteAll(['product_id' => $id]);
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }