Browse Source

[Espace producteur] Accueil : enlever produits présents uniquement sur un point de vente à accès restreint #909

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
e47168ab00
3 changed files with 35 additions and 3 deletions
  1. +7
    -0
      common/logic/PointSale/PointSale/Service/PointSaleSolver.php
  2. +19
    -0
      common/logic/Product/Product/Service/ProductSolver.php
  3. +9
    -3
      producer/controllers/SiteController.php

+ 7
- 0
common/logic/PointSale/PointSale/Service/PointSaleSolver.php View File

return $str; return $str;
} }


public function isPublic(PointSale $pointSale): bool
{
if($pointSale->restricted_access || ($pointSale->code && strlen($pointSale->code))) {
return false;
}


return true;
}
} }

+ 19
- 0
common/logic/Product/Product/Service/ProductSolver.php View File

use common\helpers\Price; use common\helpers\Price;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\PointSale\PointSale\Model\PointSale; use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Service\PointSaleSolver;
use common\logic\Product\Product\Model\Product; use common\logic\Product\Product\Model\Product;
use common\logic\Product\ProductPrice\Service\ProductPriceSolver; use common\logic\Product\ProductPrice\Service\ProductPriceSolver;
use common\logic\SolverInterface; use common\logic\SolverInterface;
class ProductSolver extends AbstractService implements SolverInterface class ProductSolver extends AbstractService implements SolverInterface
{ {
protected ProductPriceSolver $productPriceSolver; protected ProductPriceSolver $productPriceSolver;
protected PointSaleSolver $pointSaleSolver;


public function loadDependencies(): void public function loadDependencies(): void
{ {
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); $this->productPriceSolver = $this->loadService(ProductPriceSolver::class);
$this->pointSaleSolver = $this->loadService(PointSaleSolver::class);
} }


public function getPrice(Product $product, array $params = []): ?float public function getPrice(Product $product, array $params = []): ?float
return $quantityMax; return $quantityMax;
} }

public function isPublic(Product $product): bool
{
if($product->available_on_points_sale) {
return true;
}
else {
foreach($product->productPointSale as $productPointSale) {
if($productPointSale->pointSale && $this->pointSaleSolver->isPublic($productPointSale->pointSale)) {
return true;
}
}
}

return false;
}
} }

+ 9
- 3
producer/controllers/SiteController.php View File

'active' => true, 'active' => true,
'id_product_category' => null, 'id_product_category' => null,
]) ])
->with('productPointSale')
->orderBy('order ASC'); ->orderBy('order ASC');


$dataProviderProducts = new ActiveDataProvider([ $dataProviderProducts = new ActiveDataProvider([
'sort' => false, 'sort' => false,
]); ]);


$models = $dataProviderProducts->getModels();
foreach($models as $index => $product) {
if(!$productManager->isPublic($product)) {
unset($models[$index]);
}
}
$dataProviderProducts->setModels($models);

$products = $queryProducts->all(); $products = $queryProducts->all();
foreach ($dataProviderProductsByCategories as $dataProvider) { foreach ($dataProviderProductsByCategories as $dataProvider) {
$products = array_merge( $products = array_merge(
if (strlen($email) && $model->sendEmail($email)) { if (strlen($email) && $model->sendEmail($email)) {
$isSent = true; $isSent = true;
} }
else {
die('email : '.$email);
}
} }


if ($isSent) { if ($isSent) {

Loading…
Cancel
Save