Browse Source

Bug parent sur productCategory

master
Fab 4 years ago
parent
commit
aea7a59989
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      ShopBundle/Controller/Admin/AdminController.php

+ 9
- 1
ShopBundle/Controller/Admin/AdminController.php View File

@@ -280,6 +280,7 @@ class AdminController extends EasyAdminController
$allChilds = $form->all();
foreach ($allChilds as $child) {
$statusInterface = false;
$treeInterface = false;
$type = $child->getConfig()->getType()->getInnerType();

if ($type instanceof EntityType) {
@@ -294,6 +295,10 @@ class AdminController extends EasyAdminController
if (in_array('Lc\ShopBundle\Context\StatusInterface', $classImplements)) {
$statusInterface = true;
}

if (in_array('Lc\ShopBundle\Context\TreeInterface', $classImplements)) {
$treeInterface = true;
}
$propertyMerchant = 'merchant';
if($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's' ;
@@ -304,7 +309,7 @@ class AdminController extends EasyAdminController
'label' => $passedOptions['label'],
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--',
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface) {
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) {
$queryBuilder = $repo->createQueryBuilder('e');
$propertyMerchant = 'e.' . $propertyMerchant;

@@ -317,6 +322,9 @@ class AdminController extends EasyAdminController
if($statusInterface){
$queryBuilder->andWhere('e.status >= 0');
}
if($treeInterface && $child->getName() =='parent'){
$queryBuilder->andWhere('e.parent is null');
}
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());

return $queryBuilder;

Loading…
Cancel
Save