Selaa lähdekoodia

Refactoring repositoryQuery id d'entité

packProduct
Fabien Normand 3 vuotta sitten
vanhempi
commit
c3a6f9924f
4 muutettua tiedostoa jossa 18 lisäystä ja 3 poistoa
  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 Näytä tiedosto

@@ -29,6 +29,7 @@ class TicketFieldDefinition extends SovTicketFieldDefinition
return array_merge(parent::configureFields(), [
'type' => ChoiceField::new('type')
->autocomplete()
->setSortable(true)
->setChoices(
$this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),

+ 7
- 1
Field/Filter/ProductCategoriesFilter.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Field\Filter;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Field\Filter\FilterTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -43,7 +44,12 @@ class ProductCategoriesFilter extends AssociationFilter
{
$fieldProperty = $this->getFieldProperty($fieldDto);
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 Näytä tiedosto

@@ -104,6 +104,14 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
->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
{

+ 2
- 2
Repository/Product/ProductStore.php Näytä tiedosto

@@ -45,7 +45,7 @@ class ProductStore extends AbstractStore
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantityNegative();
$query->groupBy('pf.id');
$query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find();

foreach ($productListAvailableQuantityNegative as $i=>$product) {
@@ -62,7 +62,7 @@ class ProductStore extends AbstractStore
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative();
$query->groupBy('pf.id');
$query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find();

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

Loading…
Peruuta
Tallenna