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 @@
= $form->field($model, 'in_menu')
->checkbox() ?>
+
+ = $form->field($model, 'sort') ?>
= Html::submitButton(
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php
index e9704f4..c271cd6 100755
--- a/common/modules/product/models/Brand.php
+++ b/common/modules/product/models/Brand.php
@@ -19,6 +19,7 @@
* @property string $seo_text
* @property string $name
* @property string $description
+ * @property integer $sort
* @property Product[] $products
*/
class Brand extends ActiveRecord
@@ -74,7 +75,10 @@
'string',
],
[
- [ 'brand_name_id' ],
+ [
+ 'brand_name_id',
+ 'sort',
+ ],
'integer',
],
[
@@ -139,6 +143,7 @@
'seo_text' => 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