浏览代码

[backend] Ajout de produits : produit en dernier dans la liste

dev
父节点
当前提交
927b9ef0c9
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. +5
    -0
      backend/controllers/ProductController.php
  2. +1
    -1
      common/models/ProductSearch.php

+ 5
- 0
backend/controllers/ProductController.php 查看文件

@@ -112,6 +112,11 @@ class ProductController extends BackendController

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$lastProductOrder = Product::find()->orderBy('order DESC')->one() ;
if($lastProductOrder) {
$model->order = $lastProductOrder->order ++ ;
}
Upload::uploadFile($model, 'photo');
$model->save();


+ 1
- 1
common/models/ProductSearch.php 查看文件

@@ -69,7 +69,7 @@ class ProductSearch extends Product
'query' => $query,
'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']],
'pagination' => [
'pageSize' => 20,
'pageSize' => 1000,
],
]);

正在加载...
取消
保存