Commit d52ef1bb76f698b2233df801210da0f360b8b169
Merge remote-tracking branch 'origin/master'
Showing
2 changed files
with
29 additions
and
23 deletions
Show diff stats
models/Category.php
@@ -288,6 +288,7 @@ | @@ -288,6 +288,7 @@ | ||
288 | $query3 = ( new Query() )->select( | 288 | $query3 = ( new Query() )->select( |
289 | [ | 289 | [ |
290 | 'tax_option.*', | 290 | 'tax_option.*', |
291 | + 'tax_option.id as tax_option_id', | ||
291 | 'tax_option_lang.alias as option_alias', | 292 | 'tax_option_lang.alias as option_alias', |
292 | 'tax_group_lang.alias as group_alias', | 293 | 'tax_group_lang.alias as group_alias', |
293 | 'tax_option_lang.value as value', | 294 | 'tax_option_lang.value as value', |
models/ProductFrontendSearch.php
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | use yii\base\Model; | 7 | use yii\base\Model; |
8 | use yii\data\ActiveDataProvider; | 8 | use yii\data\ActiveDataProvider; |
9 | use yii\data\ArrayDataProvider; | 9 | use yii\data\ArrayDataProvider; |
10 | + use yii\data\Sort; | ||
10 | use yii\db\ActiveQuery; | 11 | use yii\db\ActiveQuery; |
11 | 12 | ||
12 | use artweb\artbox\ecommerce\models\Product; | 13 | use artweb\artbox\ecommerce\models\Product; |
@@ -63,35 +64,39 @@ | @@ -63,35 +64,39 @@ | ||
63 | public function search($category = null, $params = [], $in_stock = true) | 64 | public function search($category = null, $params = [], $in_stock = true) |
64 | { | 65 | { |
65 | 66 | ||
67 | + $sort = new Sort( | ||
68 | + [ | ||
69 | + 'attributes' => [ | ||
70 | + 'name_asc' => [ | ||
71 | + 'asc' => [ 'lang.title' => SORT_ASC ], | ||
72 | + 'desc' => [ 'lang.title' => SORT_ASC ], | ||
73 | + 'default' => SORT_ASC, | ||
74 | + 'label' => 'имени от А до Я', | ||
75 | + ], | ||
76 | + 'name_desc' => [ | ||
77 | + 'asc' => [ 'lang.title' => SORT_DESC ], | ||
78 | + 'desc' => [ 'lang.title' => SORT_DESC ], | ||
79 | + 'default' => SORT_DESC, | ||
80 | + 'label' => 'имени от Я до А', | ||
81 | + ], | ||
82 | + 'price' => [ | ||
83 | + 'asc' => [ 'enabledVariants.price' => SORT_ASC ], | ||
84 | + 'desc' => [ 'enabledVariants.price' => SORT_DESC ], | ||
85 | + 'default' => SORT_DESC, | ||
86 | + 'label' => 'по цене', | ||
87 | + ], | ||
88 | + ], | ||
89 | + ] | ||
90 | + ); | ||
91 | + | ||
66 | $dataProvider = new ArrayDataProvider( | 92 | $dataProvider = new ArrayDataProvider( |
67 | [ | 93 | [ |
68 | 'allModels' => $this->getSearchQuery($category, $params, $in_stock) | 94 | 'allModels' => $this->getSearchQuery($category, $params, $in_stock) |
69 | - ->all(), | 95 | + ->with('variant')->all(), |
70 | 'pagination' => [ | 96 | 'pagination' => [ |
71 | 'pageSize' => 10, | 97 | 'pageSize' => 10, |
72 | ], | 98 | ], |
73 | - 'sort' => [ | ||
74 | - 'attributes' => [ | ||
75 | - 'name_asc' => [ | ||
76 | - 'asc' => [ 'name' => SORT_ASC ], | ||
77 | - 'desc' => [ 'name' => SORT_ASC ], | ||
78 | - 'default' => SORT_ASC, | ||
79 | - 'label' => 'имени от А до Я', | ||
80 | - ], | ||
81 | - 'name_desc' => [ | ||
82 | - 'asc' => [ 'name' => SORT_DESC ], | ||
83 | - 'desc' => [ 'name' => SORT_DESC ], | ||
84 | - 'default' => SORT_DESC, | ||
85 | - 'label' => 'имени от Я до А', | ||
86 | - ], | ||
87 | - 'price' => [ | ||
88 | - 'asc' => [ 'price' => SORT_ASC ], | ||
89 | - 'desc' => [ 'price' => SORT_DESC ], | ||
90 | - 'default' => SORT_DESC, | ||
91 | - 'label' => 'по цене', | ||
92 | - ], | ||
93 | - ], | ||
94 | - ], | 99 | + 'sort' => $sort, |
95 | ] | 100 | ] |
96 | ); | 101 | ); |
97 | 102 |