Bladeren bron

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

feature/souke
Guillaume Bourgeois 11 maanden geleden
bovenliggende
commit
cf4329a99f
2 gewijzigde bestanden met toevoegingen van 9 en 5 verwijderingen
  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 Bestand weergeven

@@ -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 Bestand weergeven

@@ -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);
}


Laden…
Annuleren
Opslaan