Browse Source

[Administration] Produits : import CSV prix spécifiques #959

refactoring
Guillaume 1 year ago
parent
commit
4e09aab8c0
2 changed files with 4 additions and 1 deletions
  1. +3
    -0
      backend/controllers/ProductController.php
  2. +1
    -1
      backend/forms/ProductPriceUploadForm.php

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

@@ -51,6 +51,7 @@ use common\logic\Product\ProductPrice\Model\ProductPriceSearch;
use common\logic\User\UserProducer\Model\UserProducer;
use Yii;
use yii\filters\AccessControl;
use yii\helpers\BaseFileHelper;
use yii\helpers\Html;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@@ -375,6 +376,8 @@ class ProductController extends BackendController
if ($model->file && $model->validate()) {
$productPriceCsvArray = array_map(function($data) { return str_getcsv($data,";");}, file($model->file->tempName));

//die('mime type : '.BaseFileHelper::getMimeType($model->file->tempName));

if(!$productPriceCsvArray || count($productPriceCsvArray[0]) != 6) {
$this->setFlash('error', "Format de fichier invalide. Veuillez vérifier que le séparateur de champs de votre fichier est bien \";\".");
}

+ 1
- 1
backend/forms/ProductPriceUploadForm.php View File

@@ -21,7 +21,7 @@ class ProductPriceUploadForm extends Model
public function rules()
{
return [
[['file'], 'file'],
[['file'], 'file', 'skipOnEmpty' => false, 'mimeTypes' => 'text/csv, text/plain'],
];
}


Loading…
Cancel
Save