Bläddra i källkod

Refactoring repositoryQuery id d'entité

packProduct
Fabien Normand 3 år sedan
förälder
incheckning
c3a6f9924f
4 ändrade filer med 18 tillägg och 3 borttagningar
  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 Visa fil

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

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

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

@@ -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) {

Laddar…
Avbryt
Spara