소스 검색

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

feature/souke
Guillaume Bourgeois 1 년 전
부모
커밋
1c266a15f9
1개의 변경된 파일14개의 추가작업 그리고 8개의 파일을 삭제
  1. +14
    -8
      producer/controllers/SiteController.php

+ 14
- 8
producer/controllers/SiteController.php 파일 보기

@@ -110,6 +110,7 @@ class SiteController extends ProducerBaseController
],
'sort' => false,
]);
$this->filterProductsPublic($dataProviderProductsByCategories[$productCategory->id]);
}

$queryProducts = Product::find()
@@ -128,14 +129,7 @@ class SiteController extends ProducerBaseController
],
'sort' => false,
]);

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

$products = $queryProducts->all();
foreach ($dataProviderProductsByCategories as $dataProvider) {
@@ -167,6 +161,18 @@ class SiteController extends ProducerBaseController
]);
}

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

/**
* Affiche et traite le formulaire de contact dédié aux producteurs.
*/

Loading…
취소
저장