public function watchedSearch($params)
 {
     $query = Yii::$app->user->identity->getRecentlyProducts()->select(['{{product}}.*', 'IF(round(sum(product_review.rating) / count(product.reviews_count)) IS NULL, 0, rating) as rating'])->joinWith(['productReviews', 'recentProducts'])->groupBy('{{product}}.id');
     $sort = new Sort(['defaultOrder' => ['recent' => SORT_ASC], 'attributes' => ArrayHelper::merge(['recent' => ['asc' => ['recent_product.created_at' => SORT_DESC], 'label' => 'Recently', 'defaultOrder' => SORT_ASC], 'old' => ['asc' => ['recent_product.created_at' => SORT_ASC], 'label' => 'Old', 'defaultOrder' => SORT_ASC]], Product::getSortAttributes())]);
     $viewSort = new Sort(['sortParam' => 'view', 'attributes' => [Product::VIEW_SORT_LIST, Product::VIEW_SORT_BLOCK]]);
     $this->load($params);
     $sortParam = Yii::$app->request->getQueryParam('view');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => $sort, 'pagination' => ['pageSizeParam' => false, 'pageSize' => $sortParam === Product::VIEW_SORT_BLOCK ? self::FAVORITES_PAGINATION_SIZE_BLOCK : self::FAVORITES_PAGINATION_SIZE_LIST]]);
     Yii::$app->controller->view->params['viewSort'] = $viewSort;
     Yii::$app->controller->view->params['sort'] = $sort;
     Yii::$app->controller->view->params['searchModel'] = $this;
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'reviews_count' => $this->reviews_count, 'brand_id' => $this->brand_id, 'comment_count' => $this->comment_count, 'category_id' => $this->category_id, 'UI' => $this->ui]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'full_description', $this->full_description])->andFilterWhere(['like', 'short_description', $this->short_description])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'ui', $this->ui]);
     return $dataProvider;
 }