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
1c266a15f9
1 changed files with 14 additions and 8 deletions
  1. +14
    -8
      producer/controllers/SiteController.php

+ 14
- 8
producer/controllers/SiteController.php View File

], ],
'sort' => false, 'sort' => false,
]); ]);
$this->filterProductsPublic($dataProviderProductsByCategories[$productCategory->id]);
} }


$queryProducts = Product::find() $queryProducts = Product::find()
], ],
'sort' => false, '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(); $products = $queryProducts->all();
foreach ($dataProviderProductsByCategories as $dataProvider) { foreach ($dataProviderProductsByCategories as $dataProvider) {
]); ]);
} }


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. * Affiche et traite le formulaire de contact dédié aux producteurs.
*/ */

Loading…
Cancel
Save