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,6 +18,7 @@ | ||
| 18 | * | 18 | * |
| 19 | * @todo Write doc for ArtboxTreeBehavior | 19 | * @todo Write doc for ArtboxTreeBehavior |
| 20 | * @property integer $id | 20 | * @property integer $id |
| 21 | + * @property integer $sort | ||
| 21 | * @property integer $remote_id | 22 | * @property integer $remote_id |
| 22 | * @property integer $parent_id | 23 | * @property integer $parent_id |
| 23 | * @property string $path | 24 | * @property string $path |
| @@ -67,7 +68,7 @@ | @@ -67,7 +68,7 @@ | ||
| 67 | return [ | 68 | return [ |
| 68 | 'artboxtree' => [ | 69 | 'artboxtree' => [ |
| 69 | 'class' => ArtboxTreeBehavior::className(), | 70 | 'class' => ArtboxTreeBehavior::className(), |
| 70 | - 'keyNameGroup' => null, | 71 | + 'keyNameGroup' => NULL, |
| 71 | 'keyNamePath' => 'path', | 72 | 'keyNamePath' => 'path', |
| 72 | ], | 73 | ], |
| 73 | 'language' => [ | 74 | 'language' => [ |
| @@ -88,9 +89,6 @@ | @@ -88,9 +89,6 @@ | ||
| 88 | ], | 89 | ], |
| 89 | ]; | 90 | ]; |
| 90 | } | 91 | } |
| 91 | - | ||
| 92 | - | ||
| 93 | - | ||
| 94 | 92 | ||
| 95 | /** | 93 | /** |
| 96 | * @inheritdoc | 94 | * @inheritdoc |
| @@ -111,6 +109,7 @@ | @@ -111,6 +109,7 @@ | ||
| 111 | 'parent_id', | 109 | 'parent_id', |
| 112 | 'depth', | 110 | 'depth', |
| 113 | 'product_unit_id', | 111 | 'product_unit_id', |
| 112 | + 'sort', | ||
| 114 | ], | 113 | ], |
| 115 | 'integer', | 114 | 'integer', |
| 116 | ], | 115 | ], |
| @@ -138,6 +137,7 @@ | @@ -138,6 +137,7 @@ | ||
| 138 | 'imageUrl' => Yii::t('product', 'Image'), | 137 | 'imageUrl' => Yii::t('product', 'Image'), |
| 139 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | 138 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), |
| 140 | 'remote_id' => Yii::t('product', 'Remote ID'), | 139 | 'remote_id' => Yii::t('product', 'Remote ID'), |
| 140 | + 'sort' => Yii::t('product', 'Порядок вывода'), | ||
| 141 | ]; | 141 | ]; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| @@ -212,7 +212,7 @@ | @@ -212,7 +212,7 @@ | ||
| 212 | { | 212 | { |
| 213 | if (parent::beforeSave($insert)) { | 213 | if (parent::beforeSave($insert)) { |
| 214 | 214 | ||
| 215 | - if (empty( $this->parent_id )) { | 215 | + if (empty($this->parent_id)) { |
| 216 | $this->parent_id = 0; | 216 | $this->parent_id = 0; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| @@ -247,11 +247,17 @@ | @@ -247,11 +247,17 @@ | ||
| 247 | ) | 247 | ) |
| 248 | ->innerJoin('product', 'product.id = product_variant.product_id') | 248 | ->innerJoin('product', 'product.id = product_variant.product_id') |
| 249 | ->innerJoin('product_category', 'product_category.product_id = product.id') | 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 | ->andWhere( | 261 | ->andWhere( |
| 256 | [ | 262 | [ |
| 257 | '!=', | 263 | '!=', |
| @@ -275,11 +281,17 @@ | @@ -275,11 +281,17 @@ | ||
| 275 | ->innerJoin('product', 'product.id = product_option.product_id') | 281 | ->innerJoin('product', 'product.id = product_option.product_id') |
| 276 | ->innerJoin('product_category', 'product_category.product_id = product.id') | 282 | ->innerJoin('product_category', 'product_category.product_id = product.id') |
| 277 | ->innerJoin('product_variant', 'product_variant.product_id = product.id') | 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 | ->andWhere( | 295 | ->andWhere( |
| 284 | [ | 296 | [ |
| 285 | '!=', | 297 | '!=', |
views/category/_form.php
| @@ -39,6 +39,10 @@ | @@ -39,6 +39,10 @@ | ||
| 39 | ) | 39 | ) |
| 40 | ->label(Yii::t('product', 'Parent category')) ?> | 40 | ->label(Yii::t('product', 'Parent category')) ?> |
| 41 | 41 | ||
| 42 | + <?php | ||
| 43 | + echo $form->field($model, 'sort'); | ||
| 44 | + ?> | ||
| 45 | + | ||
| 42 | <?= $form->field($model, 'image') | 46 | <?= $form->field($model, 'image') |
| 43 | ->widget( | 47 | ->widget( |
| 44 | \kartik\file\FileInput::className(), | 48 | \kartik\file\FileInput::className(), |