Quellcode durchsuchen

Correctif DepositoryZone

develop
Guillaume vor 3 Jahren
Ursprung
Commit
815dd0aa82
2 geänderte Dateien mit 52 neuen und 36 gelöschten Zeilen
  1. +17
    -1
      ShopBundle/Controller/Backend/ProductFamilyController.php
  2. +35
    -35
      ShopBundle/Repository/ProductRepository.php

+ 17
- 1
ShopBundle/Controller/Backend/ProductFamilyController.php Datei anzeigen

@@ -2,8 +2,10 @@

namespace Lc\ShopBundle\Controller\Backend;

use App\Entity\DepositoryZone;
use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\ImageInterface;
@@ -19,6 +21,7 @@ use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType;
use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -183,7 +186,6 @@ class ProductFamilyController extends AdminController
'required' => false
));


$formBuilder->add('products', CollectionType::class, array(
'label' => 'Déclinaisons',
'entry_type' => ProductType::class,
@@ -194,6 +196,20 @@ class ProductFamilyController extends AdminController
)
);

$currentMerchant = $this->merchantUtils->getMerchantCurrent();

$formBuilder->add('depositoryZone', EntityType::class, [
'class' => DepositoryZone::class,
'query_builder' => function (EntityRepository $er) use ($currentMerchant) {
return $er->createQueryBuilder('d')
->where('d.merchant = :currentMerchant')
->setParameter('currentMerchant', $currentMerchant)
->andWhere('d.status > 0');
},
'label' => 'Zone de dépot',
'required' => false
]);

$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);

return $formBuilder;

+ 35
- 35
ShopBundle/Repository/ProductRepository.php Datei anzeigen

@@ -14,42 +14,42 @@ use Lc\ShopBundle\Model\ProductFamily;
*/
class ProductRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return ProductInterface::class;
}


public function findProductByAvailabilitiesNegative()
{
$qb = $this->createQueryBuilder('e');
$qb->innerJoin('e.productFamily', 'productFamily');
$qb->addSelect('productFamily');
$qb->where('productFamily.merchant = :currentMerchant');
$qb->andWhere('productFamily.status = 1');
$qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId());

$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->andX(
$qb->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
public function getInterfaceClass()
{
return ProductInterface::class;
}


public function findProductByAvailabilitiesNegative()
{
$qb = $this->createQueryBuilder('e');
$qb->innerJoin('e.productFamily', 'productFamily');
$qb->addSelect('productFamily');
$qb->where('productFamily.merchant = :currentMerchant');
$qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId());
$qb->andWhere('productFamily.status = 1');

$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->andX(
$qb->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
$qb->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
)
'productFamily.availableQuantity < 0 '
),
$qb->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
)
);
$qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY);
$qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
$qb->groupBy('productFamily.id');

return $qb->getQuery()->getResult();
}
)
);
$qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY);
$qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
$qb->groupBy('productFamily.id');

return $qb->getQuery()->getResult();
}

}

Laden…
Abbrechen
Speichern