Bläddra i källkod

Intégration des RepositoryQuery dans EasyAdmin

packProduct
Fabien Normand 3 år sedan
förälder
incheckning
241880137b
25 ändrade filer med 155 tillägg och 30 borttagningar
  1. +8
    -12
      Controller/AdminControllerTrait.php
  2. +6
    -0
      Controller/Config/TaxRateAdminController.php
  3. +5
    -0
      Controller/Config/UnitAdminController.php
  4. +6
    -0
      Controller/Credit/CreditHistoryAdminController.php
  5. +6
    -0
      Controller/Merchant/MerchantAdminController.php
  6. +1
    -0
      Controller/Newsletter/NewsletterAdminController.php
  7. +7
    -0
      Controller/Order/OrderShopAdminController.php
  8. +19
    -0
      Controller/Order/OrderStatusAdminController.php
  9. +6
    -0
      Controller/PointSale/PointSaleAdminController.php
  10. +7
    -0
      Controller/Product/ProductCategoryAdminController.php
  11. +15
    -7
      Controller/Product/ProductFamilyAdminController.php
  12. +6
    -0
      Controller/Reduction/ReductionCartAdminController.php
  13. +6
    -0
      Controller/Reduction/ReductionCatalogAdminController.php
  14. +8
    -0
      Controller/Reduction/ReductionCreditAdminController.php
  15. +6
    -0
      Controller/Section/OpeningAdminController.php
  16. +7
    -0
      Controller/Section/SectionAdminController.php
  17. +0
    -2
      Controller/Site/NewsAdminController.php
  18. +2
    -0
      Controller/Site/PageAdminController.php
  19. +3
    -1
      Controller/Ticket/TicketAdminController.php
  20. +5
    -0
      Controller/User/UserMerchantAdminController.php
  21. +3
    -4
      Field/Filter/ProductCategoriesFilter.php
  22. +1
    -1
      Model/Product/ProductFamilyModel.php
  23. +1
    -0
      Repository/Order/OrderProductRepositoryQuery.php
  24. +2
    -2
      Repository/Product/ProductFamilyRepositoryQuery.php
  25. +19
    -1
      Repository/Product/ProductRepositoryQuery.php

+ 8
- 12
Controller/AdminControllerTrait.php Visa fil

@@ -56,6 +56,7 @@ use Lc\CaracoleBundle\Resolver\SectionResolver;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Response;
@@ -124,33 +125,28 @@ trait AdminControllerTrait
return $responseParameters;
}

public function createIndexQueryBuilder(
public function createIndexRepositoryQuery(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {
$queryBuilder = parent::createIndexQueryBuilder(
): RepositoryQueryInterface {
$repositoryQuery = parent::createIndexRepositoryQuery(
$searchDto,
$entityDto,
$fields,
$filters
);

if ($this->isInstanceOf(FilterMerchantInterface::class)) {
$queryBuilder->andWhereMerchant('entity', $this->get(MerchantResolver::class)->getCurrent());
}

if ($this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$queryBuilder->andWhere(':merchant MEMBER OF entity.merchants');
$queryBuilder->setParameter('merchant', $this->get(MerchantResolver::class)->getCurrent());
if ($this->isInstanceOf(FilterMerchantInterface::class) || $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$repositoryQuery->filterByMerchant($this->get(MerchantResolver::class)->getCurrent());
}

if ($this->isInstanceOf(FilterSectionInterface::class)) {
$queryBuilder->andWhereSection('entity', $this->get(SectionResolver::class)->getCurrent());
$repositoryQuery->filterBySection($this->get(SectionResolver::class)->getCurrent());
}

return $queryBuilder;
return $repositoryQuery;
}



+ 6
- 0
Controller/Config/TaxRateAdminController.php Visa fil

@@ -9,11 +9,17 @@ use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\TaxRateFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class TaxRateAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(TaxRateContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return [

+ 5
- 0
Controller/Config/UnitAdminController.php Visa fil

@@ -11,10 +11,15 @@ use Lc\CaracoleBundle\Container\Config\UnitContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\UnitFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class UnitAdminController extends AbstractAdminController
{
use AdminControllerTrait;
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(UnitContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{

+ 6
- 0
Controller/Credit/CreditHistoryAdminController.php Visa fil

@@ -29,12 +29,18 @@ use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\Order\OrderPaymentModel;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class CreditHistoryAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(CreditHistoryContainer::class)->getRepositoryQuery();
}

public function overrideGlobalActions(?ActionCollection $actions): void
{
parent::overrideGlobalActions($actions);

+ 6
- 0
Controller/Merchant/MerchantAdminController.php Visa fil

@@ -14,11 +14,17 @@ use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class MerchantAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(MerchantContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
$panel = parent::configureFields($pageName);

+ 1
- 0
Controller/Newsletter/NewsletterAdminController.php Visa fil

@@ -6,6 +6,7 @@ use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class NewsletterAdminController extends SovNewsletterAdminController
{

+ 7
- 0
Controller/Order/OrderShopAdminController.php Visa fil

@@ -6,13 +6,20 @@ namespace Lc\CaracoleBundle\Controller\Order;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class OrderShopAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(OrderShopContainer::class)->getRepositoryQuery();
}
}

+ 19
- 0
Controller/Order/OrderStatusAdminController.php Visa fil

@@ -0,0 +1,19 @@
<?php

namespace Lc\CaracoleBundle\Controller\Order;


use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class OrderStatusAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(OrderStatusContainer::class)->getRepositoryQuery();
}
}

+ 6
- 0
Controller/PointSale/PointSaleAdminController.php Visa fil

@@ -5,11 +5,17 @@ namespace Lc\CaracoleBundle\Controller\PointSale;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class PointSaleAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(PointSaleContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getPointSaleContainer()

+ 7
- 0
Controller/Product/ProductCategoryAdminController.php Visa fil

@@ -8,16 +8,23 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class ProductCategoryAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ProductCategoryContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return array_merge(

+ 15
- 7
Controller/Product/ProductFamilyAdminController.php Visa fil

@@ -14,6 +14,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Field\Address\AddressField;
@@ -22,6 +23,7 @@ use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

@@ -29,16 +31,22 @@ abstract class ProductFamilyAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
{
$queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);

$queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
$queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
$queryBuilder->addOrderBy('entity.id');
return $queryBuilder;
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
}

// public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
// {
// $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
//
// $queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
// $queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
// $queryBuilder->addOrderBy('entity.id');
// return $queryBuilder;
// }

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

+ 6
- 0
Controller/Reduction/ReductionCartAdminController.php Visa fil

@@ -6,10 +6,12 @@ namespace Lc\CaracoleBundle\Controller\Reduction;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class ReductionCartAdminController extends AbstractAdminController
@@ -17,5 +19,9 @@ abstract class ReductionCartAdminController extends AbstractAdminController
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ReductionCartContainer::class)->getRepositoryQuery();
}

}

+ 6
- 0
Controller/Reduction/ReductionCatalogAdminController.php Visa fil

@@ -6,10 +6,12 @@ namespace Lc\CaracoleBundle\Controller\Reduction;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class ReductionCatalogAdminController extends AbstractAdminController
@@ -17,5 +19,9 @@ abstract class ReductionCatalogAdminController extends AbstractAdminController
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ReductionCatalogContainer::class)->getRepositoryQuery();
}

}

+ 8
- 0
Controller/Reduction/ReductionCreditAdminController.php Visa fil

@@ -6,13 +6,21 @@ namespace Lc\CaracoleBundle\Controller\Reduction;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class ReductionCreditAdminController extends AbstractAdminController
{
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ReductionCreditContainer::class)->getRepositoryQuery();
}
}

+ 6
- 0
Controller/Section/OpeningAdminController.php Visa fil

@@ -11,11 +11,17 @@ use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class OpeningAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(OpeningContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
$fields = parent::configureFields($pageName);

+ 7
- 0
Controller/Section/SectionAdminController.php Visa fil

@@ -16,6 +16,7 @@ use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionFactory;
use Symfony\Component\Routing\Annotation\Route;
@@ -24,6 +25,12 @@ abstract class SectionAdminController extends AbstractAdminController
{
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(SectionContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return array_merge(

+ 0
- 2
Controller/Site/NewsAdminController.php Visa fil

@@ -3,8 +3,6 @@
namespace Lc\CaracoleBundle\Controller\Site;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Site\NewsFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController;

+ 2
- 0
Controller/Site/PageAdminController.php Visa fil

@@ -7,11 +7,13 @@ use Lc\CaracoleBundle\Factory\Site\PageFactory;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class PageAdminController extends SovPageAdminController
{
use AdminControllerTrait;


public function createEntity(string $entityFqcn)
{
return $this->getPageContainer()

+ 3
- 1
Controller/Ticket/TicketAdminController.php Visa fil

@@ -2,13 +2,15 @@

namespace Lc\CaracoleBundle\Controller\Ticket;

use App\Entity\Ticket\Ticket;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController;
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class TicketAdminController extends SovTicketAdminController
abstract class TicketAdminController extends SovTicketAdminController
{
use AdminControllerTrait;


+ 5
- 0
Controller/User/UserMerchantAdminController.php Visa fil

@@ -38,6 +38,7 @@ use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Response;

@@ -46,6 +47,10 @@ abstract class UserMerchantAdminController extends AbstractAdminController
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(UserMerchantContainer::class)->getRepositoryQuery();
}
public function overrideEntitiesActions(?EntityCollection $entities): void
{
$context = $this->get(AdminContextProvider::class)->getContext();

+ 3
- 4
Field/Filter/ProductCategoriesFilter.php Visa fil

@@ -7,6 +7,7 @@ use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Field\Filter\FilterTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;

@@ -38,12 +39,10 @@ class ProductCategoriesFilter extends AssociationFilter
}


public function applyFilter(QueryBuilder $queryBuilder, string $fieldProperty, $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, $filteredValue = null)
{
if ($filteredValue !== null) {
$queryBuilder->leftJoin('entity.productCategories', 'product_categories');
$queryBuilder->andWhere(':' . $fieldProperty . ' MEMBER OF entity.' . $fieldProperty . ' OR product_categories.parent = :' . $fieldProperty);
$queryBuilder->setParameter($fieldProperty, $filteredValue);
$repositoryQuery->filterByProductCategory($filteredValue);

}
}

+ 1
- 1
Model/Product/ProductFamilyModel.php Visa fil

@@ -20,7 +20,7 @@ use Lc\SovBundle\Model\File\FileInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, ProductFamilyInterface
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, ProductFamilyInterface, FilterSectionInterface
{
use ProductPropertyTrait;


+ 1
- 0
Repository/Order/OrderProductRepositoryQuery.php Visa fil

@@ -22,6 +22,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
{
parent::__construct($repository, 'r', $paginator);
}

public function filterByOrderShop(OrderShopInterface $orderShop): self
{
return $this

+ 2
- 2
Repository/Product/ProductFamilyRepositoryQuery.php Visa fil

@@ -35,9 +35,9 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

public function filterBySection(SectionInterface $section)
public function filterBySection(SectionInterface $section,bool $addSelectProductFamilySectionProperties = true)
{
$this->joinProductFamilySectionProperties();
$this->joinProductFamilySectionProperties($addSelectProductFamilySectionProperties);
$this->andWhereSection('pfsp', $section);
$this->andWhere('pfsp.status = 1');
}

+ 19
- 1
Repository/Product/ProductRepositoryQuery.php Visa fil

@@ -12,6 +12,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductRepositoryQuery extends AbstractRepositoryQuery
{
protected bool $isJoinProductFamily =false;
protected bool $isJoinProductFamilySectionProperties =false;

public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
{
@@ -35,12 +36,29 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery
}

public function filterBySection(SectionInterface $section):self
{
$this->joinProductFamilySectionProperties(false);
$this->andWhereSection('pfsp', $section);
$this->andWhere('pfsp.status = 1');

return $this;
}
public function joinProductFamilySectionProperties(bool $addSelect = true): self
{
$this->joinProductFamily();
$this->andWhereSection('pf', $section);

if (!$this->isJoinProductFamilySectionProperties) {
$this->isJoinProductFamilySectionProperties = true;

$this->leftJoin('pf.productFamilySectionProperties', 'pfsp');
if ($addSelect) {
$this->addSelect('pfsp');
}
}
return $this;
}


public function filterIsOnline():self
{
$this->joinProductFamily();

Laddar…
Avbryt
Spara