Bläddra i källkod

ProductCategory : Correctif toString / displaySpecificDay

develop
Guillaume 3 år sedan
förälder
incheckning
8718381f96
2 ändrade filer med 9 tillägg och 5 borttagningar
  1. +4
    -2
      ShopBundle/Model/ProductCategory.php
  2. +5
    -3
      ShopBundle/Repository/ProductCategoryRepository.php

+ 4
- 2
ShopBundle/Model/ProductCategory.php Visa fil

@@ -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 Visa fil

@@ -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') ;


Laddar…
Avbryt
Spara