Browse Source

[Admin] Export totaux produits CSV : produits ordonnés par position uniquement

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
cf4329a99f
2 changed files with 9 additions and 5 deletions
  1. +1
    -1
      common/logic/Distribution/Distribution/Export/DistributionReportTotalProductCsvGenerator.php
  2. +8
    -4
      common/logic/Product/Product/Repository/ProductRepository.php

+ 1
- 1
common/logic/Distribution/Distribution/Export/DistributionReportTotalProductCsvGenerator.php View File

@@ -28,7 +28,7 @@ class DistributionReportTotalProductCsvGenerator extends AbstractGenerator imple
public function generate(Distribution $distribution, bool $save = false)
{
$datas = [];
$productsArray = $this->productRepository->findProductsByDistribution($distribution);
$productsArray = $this->productRepository->findProductsByDistribution($distribution, true,'product.order ASC');
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);

foreach($productsArray as $product) {

+ 8
- 4
common/logic/Product/Product/Repository/ProductRepository.php View File

@@ -66,8 +66,12 @@ class ProductRepository extends AbstractRepository
return $this->createDefaultQuery()->count();
}

public function queryProductsByDistribution(Distribution $distribution, bool $filterStatus = true)
public function queryProductsByDistribution(Distribution $distribution, bool $filterStatus = true, string $orderBy = null)
{
if(!$orderBy) {
$orderBy = 'product_distribution.active DESC, product.order ASC';
}

return $this->createDefaultQuery($filterStatus)
->joinWith([
'productDistribution' => function ($query) use ($distribution) {
@@ -76,15 +80,15 @@ class ProductRepository extends AbstractRepository
);
}
])
->orderBy('product_distribution.active DESC, product.order ASC');
->orderBy($orderBy);
}

/**
* Retourne les produits d'une production donnée.
*/
public function findProductsByDistribution(Distribution $distribution, bool $filterStatus = true)
public function findProductsByDistribution(Distribution $distribution, bool $filterStatus = true, string $orderBy = null)
{
$productArray = $this->queryProductsByDistribution($distribution, $filterStatus)->find();
$productArray = $this->queryProductsByDistribution($distribution, $filterStatus, $orderBy)->find();
return $this->buildProductsArrayById($productArray);
}


Loading…
Cancel
Save