/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Manufacturer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['position' => SORT_ASC]]]);
     $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, 'visible' => $this->visible, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
 public function actionBrand($alias)
 {
     /** @var $category Category */
     $category = Manufacturer::find()->where(['alias' => $alias])->one();
     if (!$category) {
         throw new HttpException(404, 'Категория товара не найдена');
     }
     $q = \Yii::$app->request->get('q');
     if (!empty($q)) {
         $products = Product::find()->where(['manufacturerId' => $category->id])->visible()->andWhere(['like', 'title', $q])->all();
     } else {
         $products = $category->products;
     }
     $route = $this->route;
     $title = 'Товары - Производители - ' . $category->title;
     return $this->render('view', ['category' => $category, 'products' => $products, 'q' => $q, 'route' => $route, 'title' => $title]);
 }