Browse Source

ProductCategory : Correctif toString / displaySpecificDay

develop
Guillaume 3 years ago
parent
commit
8718381f96
2 changed files with 9 additions and 5 deletions
  1. +4
    -2
      ShopBundle/Model/ProductCategory.php
  2. +5
    -3
      ShopBundle/Repository/ProductCategoryRepository.php

+ 4
- 2
ShopBundle/Model/ProductCategory.php View File

@@ -56,8 +56,10 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt

public function __toString()
{
// TODO: Implement __toString() method.
return $this->getTitle();
$parent = $this->getParent() ;
$title = $parent ? $parent->getTitle().' - ' : '' ;
$title .= $this->getTitle() ;
return $title ;
}

public function getParent(): ?self

+ 5
- 3
ShopBundle/Repository/ProductCategoryRepository.php View File

@@ -55,7 +55,7 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit
return $query->getQuery()->getResult();
}

public function findAllByParent($parentCategory, $withOffline = false, $withEmptyCategories = true)
public function findAllByParent($parentCategory, $withOffline = false, $withEmptyCategories = true, $filterBySpecificDay = false)
{
$query = $this->createQueryBuilder('e');
$query->andWhere('e.parent = :idParentCategory');
@@ -69,8 +69,10 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit
$query->andWhere('pf.status = 1') ;
}

$query->andWhere('e.displaySpecificDay IS NULL OR e.displaySpecificDay = :dayToday') ;
$query->setParameter('dayToday', date('N')) ;
if($filterBySpecificDay) {
$query->andWhere('e.displaySpecificDay IS NULL OR e.displaySpecificDay = :dayToday') ;
$query->setParameter('dayToday', date('N')) ;
}

$query->addOrderBy('e.position', 'ASC') ;


Loading…
Cancel
Save