Browse Source

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

dev
Guillaume Bourgeois 5 years ago
parent
commit
927b9ef0c9
2 changed files with 6 additions and 1 deletions
  1. +5
    -0
      backend/controllers/ProductController.php
  2. +1
    -1
      common/models/ProductSearch.php

+ 5
- 0
backend/controllers/ProductController.php View File



if ($model->load(Yii::$app->request->post()) && $model->save()) { 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'); Upload::uploadFile($model, 'photo');
$model->save(); $model->save();



+ 1
- 1
common/models/ProductSearch.php View File

'query' => $query, 'query' => $query,
'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']], 'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']],
'pagination' => [ 'pagination' => [
'pageSize' => 20,
'pageSize' => 1000,
], ],
]); ]);

Loading…
Cancel
Save