Pārlūkot izejas kodu

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

feature/souke
Guillaume Bourgeois pirms 1 gada
vecāks
revīzija
1c266a15f9
1 mainītis faili ar 14 papildinājumiem un 8 dzēšanām
  1. +14
    -8
      producer/controllers/SiteController.php

+ 14
- 8
producer/controllers/SiteController.php Parādīt failu

@@ -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.
*/

Notiek ielāde…
Atcelt
Saglabāt