Browse Source

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

refactoring
Guillaume Bourgeois 1 year ago
parent
commit
f1a33db2dc
1 changed files with 13 additions and 9 deletions
  1. +13
    -9
      backend/controllers/ProductController.php

+ 13
- 9
backend/controllers/ProductController.php View File



$productArray = $productManager->findProducts(); $productArray = $productManager->findProducts();
foreach($productArray as $product) { foreach($productArray as $product) {

// prix produit
$data[] = [ $data[] = [
$product->name, $product->name,
'', '',
$product->price $product->price
]; ];


// prix spécifiques
foreach($product->productPrice as $productPrice) { foreach($product->productPrice as $productPrice) {

$productPrice = $productPriceManager->findOneProductPriceById($productPrice->id); $productPrice = $productPriceManager->findOneProductPriceById($productPrice->id);


$data[] = [
$product->name,
$productPrice->user ? $userManager->getUsername($productPrice->user).' #'.$productPrice->user->id : '',
$productPrice->userGroup ? $productPrice->userGroup->name : '',
$productPrice->pointSale ? $productPrice->pointSale->name : '',
$productPrice->from_quantity ?? '',
$productPrice->price
];
if($productPrice->user || $productPrice->userGroup || $productPrice->pointSale || $productPrice->from_quantity) {
$data[] = [
$product->name,
$productPrice->user ? str_replace('#', '', $userManager->getUsername($productPrice->user)).' #'.$productPrice->user->id : '',
$productPrice->userGroup ? $productPrice->userGroup->name : '',
$productPrice->pointSale ? $productPrice->pointSale->name : '',
$productPrice->from_quantity ?? '',
$productPrice->price
];
}
} }
} }



Loading…
Cancel
Save