diff --git a/frontend/controllers/CategoryController.php b/frontend/controllers/CategoryController.php index 3a6174e..fba2f3c 100755 --- a/frontend/controllers/CategoryController.php +++ b/frontend/controllers/CategoryController.php @@ -1,6 +1,7 @@ buildQuery() ->innerJoinWith('category', false) ->andWhere([ 'product_to_category.category_id' => $model->id ]) - ->with('image', 'variants.image', 'lang'); + ->innerJoinWith('lang') + ->innerJoinWith('variant') + ->with('image', 'variants.image'); $dataProvider = new ActiveDataProvider( [ 'query' => $query, 'pagination' => [ 'pageSize' => 18, ], + 'sort' => [ + 'attributes' => [ + 'title_asc' => [ + 'asc' => [ + 'product_lang.title' => SORT_ASC, + ], + 'desc' => [ + 'product_lang.title' => SORT_ASC, + ], + 'label' => \Yii::t('app', 'по имени от А до Я'), + ], + 'title_desc' => [ + 'asc' => [ + 'product_lang.title' => SORT_DESC, + ], + 'desc' => [ + 'product_lang.title' => SORT_DESC, + ], + 'label' => \Yii::t('app', 'по имени от Я до А'), + ], + 'price_asc' => [ + 'asc' => [ + 'variant.price' => SORT_ASC, + ], + 'desc' => [ + 'variant.price' => SORT_ASC, + ], + 'label' => \Yii::t('app', 'по цене по возрастанию'), + ], + 'price_desc' => [ + 'asc' => [ + 'variant.price' => SORT_DESC, + ], + 'desc' => [ + 'variant.price' => SORT_DESC, + ], + 'label' => \Yii::t('app', 'по цене по убыванию'), + ], + ], + ], ] ); @@ -106,7 +148,7 @@ ) ->one(); $seo->setAlias($model->lang->alias); - if (!empty( $model )) { + if (!empty($model)) { if ($model->lang->alias_id !== $seo->aliasId) { throw new NotFoundHttpException('Wrong language'); } diff --git a/frontend/views/category/view.php b/frontend/views/category/view.php index 6b44812..cf85ce5 100755 --- a/frontend/views/category/view.php +++ b/frontend/views/category/view.php @@ -324,20 +324,48 @@ _________________________________________________________ --> _________________________________________________________ -->
Сортировка:
-:
+