Browse Source

Refactoring repositoryQuery id d'entité

packProduct
Fabien Normand 3 years ago
parent
commit
c3a6f9924f
4 changed files with 18 additions and 3 deletions
  1. +1
    -0
      Definition/Field/Ticket/TicketFieldDefinition.php
  2. +7
    -1
      Field/Filter/ProductCategoriesFilter.php
  3. +8
    -0
      Repository/Product/ProductFamilyRepositoryQuery.php
  4. +2
    -2
      Repository/Product/ProductStore.php

+ 1
- 0
Definition/Field/Ticket/TicketFieldDefinition.php View File

return array_merge(parent::configureFields(), [ return array_merge(parent::configureFields(), [
'type' => ChoiceField::new('type') 'type' => ChoiceField::new('type')
->autocomplete() ->autocomplete()
->setSortable(true)
->setChoices( ->setChoices(
$this->translatorAdmin->transChoices( $this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(), TicketSolver::getTypeChoices(),

+ 7
- 1
Field/Filter/ProductCategoriesFilter.php View File

use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\SovBundle\Field\Filter\AssociationFilter; use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Field\Filter\FilterTrait; use Lc\SovBundle\Field\Filter\FilterTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
{ {
$fieldProperty = $this->getFieldProperty($fieldDto); $fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) { if ($filteredValue !== null) {
$repositoryQuery->filterByProductCategory($filteredValue);
if ($filteredValue->getParent() == null) {
$param = array_merge(array($filteredValue), $filteredValue->getChildrens()->toArray());
} else {
$param = array($filteredValue);
}
$repositoryQuery->filterByProductCategoryArray($param);


} }
} }

+ 8
- 0
Repository/Product/ProductFamilyRepositoryQuery.php View File

->setParameter('category', $category->getId()); ->setParameter('category', $category->getId());
} }


public function filterByProductCategoryArray(Array $categoryArray): self
{
$this->joinProductCategories();
return $this
->andWhere(':categoryArray MEMBER OF .productCategories')
->setParameter('categoryArray', $categoryArray);
}



public function filterByPropertyNoveltyExpirationDate($dateTime = null): self public function filterByPropertyNoveltyExpirationDate($dateTime = null): self
{ {

+ 2
- 2
Repository/Product/ProductStore.php View File

$query->joinProductFamily(); $query->joinProductFamily();
$query->filterIsOnline(); $query->filterIsOnline();
$query->filterAvailableQuantityNegative(); $query->filterAvailableQuantityNegative();
$query->groupBy('pf.id');
$query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find(); $productListAvailableQuantityNegative = $query->find();


foreach ($productListAvailableQuantityNegative as $i=>$product) { foreach ($productListAvailableQuantityNegative as $i=>$product) {
$query->joinProductFamily(); $query->joinProductFamily();
$query->filterIsOnline(); $query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative(); $query->filterAvailableQuantitySupplierNegative();
$query->groupBy('pf.id');
$query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find(); $productListAvailableQuantityNegative = $query->find();


foreach ($productListAvailableQuantityNegative as $i=>$product) { foreach ($productListAvailableQuantityNegative as $i=>$product) {

Loading…
Cancel
Save