Przeglądaj źródła

Frontend : Gestion des sections spécifiques (nouveautés, gros volumes, produits bio)

reduction
Guillaume 4 lat temu
rodzic
commit
9ddae8ce49
4 zmienionych plików z 55 dodań i 11 usunięć
  1. +9
    -0
      ShopBundle/Model/ProductCategory.php
  2. +1
    -5
      ShopBundle/Model/ProductFamily.php
  3. +3
    -6
      ShopBundle/Repository/ProductCategoryRepository.php
  4. +42
    -0
      ShopBundle/Repository/ProductFamilyRepository.php

+ 9
- 0
ShopBundle/Model/ProductCategory.php Wyświetl plik

@@ -61,6 +61,15 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
return $this;
}

public function getParentCategory()
{
if($this->getParent()) {
return $this->getParent() ;
}

return $this ;
}

/**
* @return Collection|self[]
*/

+ 1
- 5
ShopBundle/Model/ProductFamily.php Wyświetl plik

@@ -358,8 +358,6 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
},false) ;
}



public function isPropertyNoveltyOnline(): ?bool
{
if($this->getPropertyNoveltyExpirationDate()) {
@@ -368,10 +366,8 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return true ;
}
}
else {
return false ;
}

return false ;
}

public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface

+ 3
- 6
ShopBundle/Repository/ProductCategoryRepository.php Wyświetl plik

@@ -30,21 +30,18 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit

public function findAllParents()
{
return $this->findByMerchantQuery()
$query = $this->findByMerchantQuery()
->andWhere('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.position', 'ASC')
->getQuery()
->getResult();
->orderBy('e.position', 'ASC') ;
return $query->getQuery()->getResult();
}

public function findAllByParent($parentCategory)
{
//$query = $this->findByMerchantQuery($this->globalParam->getCurrentMerchant()) ;
$query = $this->createQueryBuilder('e') ;
$query->andWhere('e.parent = :idParentCategory')
->setParameter('idParentCategory', $parentCategory->getId());

return $query->getQuery()->getResult() ;
}
}

+ 42
- 0
ShopBundle/Repository/ProductFamilyRepository.php Wyświetl plik

@@ -18,4 +18,46 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
return ProductFamilyInterface::class;
}

public function findNovelties()
{
$query = $this->findByMerchantQuery() ;
$query->andWhere(':now <= e.propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime()) ;
return $query->getQuery()->getResult() ;
}

public function findNoveltiesByParentCategories()
{
return $this->_productsByParentCategories($this->findNovelties()) ;
}

public function findOrganics()
{
$query = $this->findByMerchantQuery() ;
$query->andWhere('e.propertyOrganicLabel IS NOT NULL');
return $query->getQuery()->getResult() ;
}

public function findOrganicsByParentCategories()
{
return $this->_productsByParentCategories($this->findOrganics()) ;
}

public function _productsByParentCategories($products)
{
$categoriesArray = [] ;
foreach($products as $product) {
$productCategories = $product->getProductCategories() ;
$category = $productCategories[0]->getParentCategory() ;
if(!isset($categoriesArray[$category->getId()])) {
$categoriesArray[$category->getId()] = [
'category' => $category,
'products' => []
] ;
}
$categoriesArray[$category->getId()]['products'][] = $product ;
}

return $categoriesArray;
}
}

Ładowanie…
Anuluj
Zapisz