Procházet zdrojové kódy

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

feature/souke
Guillaume Bourgeois před 1 rokem
rodič
revize
cf4329a99f
2 změnil soubory, kde provedl 9 přidání a 5 odebrání
  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 Zobrazit soubor

@@ -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 Zobrazit soubor

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


Načítá se…
Zrušit
Uložit