Commit 998b4c257dfa650797ba5beb9166a835ffbfd794
1 parent
0893579c
add variantSku
Showing
2 changed files
with
15 additions
and
2 deletions
Show diff stats
models/ProductSearch.php
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | public $categoryId; | 16 | public $categoryId; |
17 | 17 | ||
18 | public $productName; | 18 | public $productName; |
19 | - | 19 | + public $variantSku; |
20 | public $variantCount; | 20 | public $variantCount; |
21 | 21 | ||
22 | public function behaviors() | 22 | public function behaviors() |
@@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
37 | [ | 37 | [ |
38 | [ | 38 | [ |
39 | 'productName', | 39 | 'productName', |
40 | + 'variantSku' | ||
40 | ], | 41 | ], |
41 | 'safe', | 42 | 'safe', |
42 | ], | 43 | ], |
@@ -132,6 +133,7 @@ | @@ -132,6 +133,7 @@ | ||
132 | 'asc' => [ 'product_lang.title' => SORT_ASC ], | 133 | 'asc' => [ 'product_lang.title' => SORT_ASC ], |
133 | 'desc' => [ 'product_lang.title' => SORT_DESC ], | 134 | 'desc' => [ 'product_lang.title' => SORT_DESC ], |
134 | ], | 135 | ], |
136 | + 'variantSku', | ||
135 | // 'brand_id' => [ | 137 | // 'brand_id' => [ |
136 | // 'asc' => [ 'brand_lang.title' => SORT_ASC ], | 138 | // 'asc' => [ 'brand_lang.title' => SORT_ASC ], |
137 | // 'desc' => [ 'brand_lang.title' => SORT_DESC ], | 139 | // 'desc' => [ 'brand_lang.title' => SORT_DESC ], |
@@ -184,6 +186,13 @@ | @@ -184,6 +186,13 @@ | ||
184 | $this->productName, | 186 | $this->productName, |
185 | ] | 187 | ] |
186 | ); | 188 | ); |
189 | + $query->andFilterWhere( | ||
190 | + [ | ||
191 | + 'ilike', | ||
192 | + 'product_variant.sku', | ||
193 | + $this->variantSku | ||
194 | + ] | ||
195 | + ); | ||
187 | 196 | ||
188 | return $dataProvider; | 197 | return $dataProvider; |
189 | } | 198 | } |
views/manage/index.php
@@ -32,7 +32,11 @@ | @@ -32,7 +32,11 @@ | ||
32 | 'dataProvider' => $dataProvider, | 32 | 'dataProvider' => $dataProvider, |
33 | 'filterModel' => $searchModel, | 33 | 'filterModel' => $searchModel, |
34 | 'columns' => [ | 34 | 'columns' => [ |
35 | - 'id', | 35 | + [ |
36 | + 'label' => Yii::t('product', 'SKU'), | ||
37 | + 'attribute' => 'variantSku', | ||
38 | + 'value' => 'variant.sku', | ||
39 | + ], | ||
36 | [ | 40 | [ |
37 | 'attribute' => 'productName', | 41 | 'attribute' => 'productName', |
38 | 'value' => 'lang.title', | 42 | 'value' => 'lang.title', |