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



public function __toString() 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 public function getParent(): ?self

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

return $query->getQuery()->getResult(); 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 = $this->createQueryBuilder('e');
$query->andWhere('e.parent = :idParentCategory'); $query->andWhere('e.parent = :idParentCategory');
$query->andWhere('pf.status = 1') ; $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') ; $query->addOrderBy('e.position', 'ASC') ;



Loading…
Cancel
Save