diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 6f59b82..7b5804d 100755 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -84,6 +84,8 @@ field($model, 'in_menu') ->checkbox() ?> + + field($model, 'sort') ?>
Yii::t('product', 'Seo Text'), 'in_menu' => Yii::t('product', 'Выводить в меню'), 'description' => Yii::t('product', 'Описание'), + 'sort' => Yii::t('product', 'Порядок'), ]; } @@ -152,12 +157,12 @@ public function getImageFile() { - return empty($this->image) ? NULL : '/storage/brands/' . $this->image; + return empty($this->image) ? null : '/storage/brands/' . $this->image; } public function getImageUrl() { - return empty($this->image) ? NULL : '/storage/brands/' . $this->image; + return empty($this->image) ? null : '/storage/brands/' . $this->image; } } diff --git a/console/migrations/m170612_153331_add_sort_column_to_brand_table.php b/console/migrations/m170612_153331_add_sort_column_to_brand_table.php new file mode 100644 index 0000000..94c2e89 --- /dev/null +++ b/console/migrations/m170612_153331_add_sort_column_to_brand_table.php @@ -0,0 +1,25 @@ +addColumn('brand', 'sort', $this->integer()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('brand', 'sort'); + } + } diff --git a/frontend/models/ProductFrontendSearch.php b/frontend/models/ProductFrontendSearch.php index 7241c58..c5a07f0 100755 --- a/frontend/models/ProductFrontendSearch.php +++ b/frontend/models/ProductFrontendSearch.php @@ -119,7 +119,10 @@ ); // $query->groupBy(['product.product_id', 'product_variant.price', 'product_variant.stock']); - $query->orderBy([ 'product_variant.stock' => SORT_DESC ]); + $query->orderBy([ + 'brand.sort' => SORT_ASC, + 'product_variant.stock' => SORT_DESC, + ]); ProductHelper::_setQueryParams($query, $params); if ($in_stock) { $query->andWhere( -- libgit2 0.21.4