From 41349ad2869885113e53bed345e394eb72c276d0 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 4 Dec 2016 23:55:27 +0200 Subject: [PATCH] -Category sort field --- models/Category.php | 42 +++++++++++++++++++++++++++--------------- views/category/_form.php | 4 ++++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/models/Category.php b/models/Category.php index 252bdec..335751a 100755 --- a/models/Category.php +++ b/models/Category.php @@ -18,6 +18,7 @@ * * @todo Write doc for ArtboxTreeBehavior * @property integer $id + * @property integer $sort * @property integer $remote_id * @property integer $parent_id * @property string $path @@ -67,7 +68,7 @@ return [ 'artboxtree' => [ 'class' => ArtboxTreeBehavior::className(), - 'keyNameGroup' => null, + 'keyNameGroup' => NULL, 'keyNamePath' => 'path', ], 'language' => [ @@ -88,9 +89,6 @@ ], ]; } - - - /** * @inheritdoc @@ -111,6 +109,7 @@ 'parent_id', 'depth', 'product_unit_id', + 'sort', ], 'integer', ], @@ -138,6 +137,7 @@ 'imageUrl' => Yii::t('product', 'Image'), 'product_unit_id' => Yii::t('product', 'Product Unit ID'), 'remote_id' => Yii::t('product', 'Remote ID'), + 'sort' => Yii::t('product', 'Порядок вывода'), ]; } @@ -212,7 +212,7 @@ { if (parent::beforeSave($insert)) { - if (empty( $this->parent_id )) { + if (empty($this->parent_id)) { $this->parent_id = 0; } @@ -247,11 +247,17 @@ ) ->innerJoin('product', 'product.id = product_variant.product_id') ->innerJoin('product_category', 'product_category.product_id = product.id') - ->innerJoin('tax_group_to_category', 'tax_group.id = tax_group_to_category.tax_group_id') - ->where(['product_category.category_id' => $this->id, - 'tax_group.is_filter' => TRUE, - 'tax_group_to_category.category_id'=>$this->id, - ]) + ->innerJoin( + 'tax_group_to_category', + 'tax_group.id = tax_group_to_category.tax_group_id' + ) + ->where( + [ + 'product_category.category_id' => $this->id, + 'tax_group.is_filter' => true, + 'tax_group_to_category.category_id' => $this->id, + ] + ) ->andWhere( [ '!=', @@ -275,11 +281,17 @@ ->innerJoin('product', 'product.id = product_option.product_id') ->innerJoin('product_category', 'product_category.product_id = product.id') ->innerJoin('product_variant', 'product_variant.product_id = product.id') - ->innerJoin('tax_group_to_category', 'tax_group.id = tax_group_to_category.tax_group_id') - ->where(['product_category.category_id' => $this->id, - 'tax_group.is_filter' => TRUE, - 'tax_group_to_category.category_id'=>$this->id, - ]) + ->innerJoin( + 'tax_group_to_category', + 'tax_group.id = tax_group_to_category.tax_group_id' + ) + ->where( + [ + 'product_category.category_id' => $this->id, + 'tax_group.is_filter' => true, + 'tax_group_to_category.category_id' => $this->id, + ] + ) ->andWhere( [ '!=', diff --git a/views/category/_form.php b/views/category/_form.php index b71f3a0..65962e2 100755 --- a/views/category/_form.php +++ b/views/category/_form.php @@ -39,6 +39,10 @@ ) ->label(Yii::t('product', 'Parent category')) ?> + field($model, 'sort'); + ?> + field($model, 'image') ->widget( \kartik\file\FileInput::className(), -- libgit2 0.21.4