Преглед на файлове

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

reduction
Guillaume преди 4 години
родител
ревизия
9ddae8ce49
променени са 4 файла, в които са добавени 55 реда и са изтрити 11 реда
  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 Целия файл

@@ -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 Целия файл

@@ -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 Целия файл

@@ -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 Целия файл

@@ -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;
}
}

Loading…
Отказ
Запис