소스 검색

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

feature/souke
Guillaume Bourgeois 1 년 전
부모
커밋
e47168ab00
3개의 변경된 파일35개의 추가작업 그리고 3개의 파일을 삭제
  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 파일 보기

@@ -82,5 +82,12 @@ class PointSaleSolver extends AbstractService implements SolverInterface
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 파일 보기

@@ -6,6 +6,7 @@ use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\AbstractService;
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\ProductPrice\Service\ProductPriceSolver;
use common\logic\SolverInterface;
@@ -13,10 +14,12 @@ use common\logic\SolverInterface;
class ProductSolver extends AbstractService implements SolverInterface
{
protected ProductPriceSolver $productPriceSolver;
protected PointSaleSolver $pointSaleSolver;

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

public function getPrice(Product $product, array $params = []): ?float
@@ -211,4 +214,20 @@ class ProductSolver extends AbstractService implements SolverInterface
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 파일 보기

@@ -118,6 +118,7 @@ class SiteController extends ProducerBaseController
'active' => true,
'id_product_category' => null,
])
->with('productPointSale')
->orderBy('order ASC');

$dataProviderProducts = new ActiveDataProvider([
@@ -128,6 +129,14 @@ class SiteController extends ProducerBaseController
'sort' => false,
]);

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

$products = $queryProducts->all();
foreach ($dataProviderProductsByCategories as $dataProvider) {
$products = array_merge(
@@ -173,9 +182,6 @@ class SiteController extends ProducerBaseController
if (strlen($email) && $model->sendEmail($email)) {
$isSent = true;
}
else {
die('email : '.$email);
}
}

if ($isSent) {

Loading…
취소
저장