Commit 41349ad2869885113e53bed345e394eb72c276d0
1 parent
04264015
-Category sort field
Showing
2 changed files
with
31 additions
and
15 deletions
Show diff stats
models/Category.php
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | * |
19 | 19 | * @todo Write doc for ArtboxTreeBehavior |
20 | 20 | * @property integer $id |
21 | + * @property integer $sort | |
21 | 22 | * @property integer $remote_id |
22 | 23 | * @property integer $parent_id |
23 | 24 | * @property string $path |
... | ... | @@ -67,7 +68,7 @@ |
67 | 68 | return [ |
68 | 69 | 'artboxtree' => [ |
69 | 70 | 'class' => ArtboxTreeBehavior::className(), |
70 | - 'keyNameGroup' => null, | |
71 | + 'keyNameGroup' => NULL, | |
71 | 72 | 'keyNamePath' => 'path', |
72 | 73 | ], |
73 | 74 | 'language' => [ |
... | ... | @@ -88,9 +89,6 @@ |
88 | 89 | ], |
89 | 90 | ]; |
90 | 91 | } |
91 | - | |
92 | - | |
93 | - | |
94 | 92 | |
95 | 93 | /** |
96 | 94 | * @inheritdoc |
... | ... | @@ -111,6 +109,7 @@ |
111 | 109 | 'parent_id', |
112 | 110 | 'depth', |
113 | 111 | 'product_unit_id', |
112 | + 'sort', | |
114 | 113 | ], |
115 | 114 | 'integer', |
116 | 115 | ], |
... | ... | @@ -138,6 +137,7 @@ |
138 | 137 | 'imageUrl' => Yii::t('product', 'Image'), |
139 | 138 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), |
140 | 139 | 'remote_id' => Yii::t('product', 'Remote ID'), |
140 | + 'sort' => Yii::t('product', 'Порядок вывода'), | |
141 | 141 | ]; |
142 | 142 | } |
143 | 143 | |
... | ... | @@ -212,7 +212,7 @@ |
212 | 212 | { |
213 | 213 | if (parent::beforeSave($insert)) { |
214 | 214 | |
215 | - if (empty( $this->parent_id )) { | |
215 | + if (empty($this->parent_id)) { | |
216 | 216 | $this->parent_id = 0; |
217 | 217 | } |
218 | 218 | |
... | ... | @@ -247,11 +247,17 @@ |
247 | 247 | ) |
248 | 248 | ->innerJoin('product', 'product.id = product_variant.product_id') |
249 | 249 | ->innerJoin('product_category', 'product_category.product_id = product.id') |
250 | - ->innerJoin('tax_group_to_category', 'tax_group.id = tax_group_to_category.tax_group_id') | |
251 | - ->where(['product_category.category_id' => $this->id, | |
252 | - 'tax_group.is_filter' => TRUE, | |
253 | - 'tax_group_to_category.category_id'=>$this->id, | |
254 | - ]) | |
250 | + ->innerJoin( | |
251 | + 'tax_group_to_category', | |
252 | + 'tax_group.id = tax_group_to_category.tax_group_id' | |
253 | + ) | |
254 | + ->where( | |
255 | + [ | |
256 | + 'product_category.category_id' => $this->id, | |
257 | + 'tax_group.is_filter' => true, | |
258 | + 'tax_group_to_category.category_id' => $this->id, | |
259 | + ] | |
260 | + ) | |
255 | 261 | ->andWhere( |
256 | 262 | [ |
257 | 263 | '!=', |
... | ... | @@ -275,11 +281,17 @@ |
275 | 281 | ->innerJoin('product', 'product.id = product_option.product_id') |
276 | 282 | ->innerJoin('product_category', 'product_category.product_id = product.id') |
277 | 283 | ->innerJoin('product_variant', 'product_variant.product_id = product.id') |
278 | - ->innerJoin('tax_group_to_category', 'tax_group.id = tax_group_to_category.tax_group_id') | |
279 | - ->where(['product_category.category_id' => $this->id, | |
280 | - 'tax_group.is_filter' => TRUE, | |
281 | - 'tax_group_to_category.category_id'=>$this->id, | |
282 | - ]) | |
284 | + ->innerJoin( | |
285 | + 'tax_group_to_category', | |
286 | + 'tax_group.id = tax_group_to_category.tax_group_id' | |
287 | + ) | |
288 | + ->where( | |
289 | + [ | |
290 | + 'product_category.category_id' => $this->id, | |
291 | + 'tax_group.is_filter' => true, | |
292 | + 'tax_group_to_category.category_id' => $this->id, | |
293 | + ] | |
294 | + ) | |
283 | 295 | ->andWhere( |
284 | 296 | [ |
285 | 297 | '!=', | ... | ... |
views/category/_form.php