You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Product;
-
- use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
-
- class ProductCategorySolver
- {
-
- protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
- public function __construct(ProductFamilySectionPropertySolver $productFamilySectionPropertySolver){
- $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
- }
-
- public function isOnline(ProductCategoryInterface $productCategory)
- {
- if ($productCategory->getParent()) {
- if ($productCategory->getStatus() && $productCategory->getParent()->getStatus()) {
- return true;
- }
- } elseif ($productCategory->getStatus()) {
- return true;
- }
- return false;
- }
-
- public function hasOnlineProductFamily(ProductCategoryInterface $productCategory){
- if($productCategory->getProductFamilies()) {
- foreach ($productCategory->getProductFamilies() as $productFamily) {
- $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $productCategory->getSection());
- //vérifie que le produit est en ligne et qu'il est actif sur cette section
- if ($productFamily->getStatus() == 1 && $productFamilySectionProperty && $productFamilySectionProperty->getStatus() == 1) {
- return true;
- }
- }
- }
-
- foreach($productCategory->getChildrens() as $productCategoryChildren){
- if($this->hasOnlineProductFamily($productCategoryChildren) && $productCategoryChildren->getStatus()==1){
- return true;
- }
- }
-
- return false;
- }
-
- }
-
|