Procházet zdrojové kódy

OrderShopRepository : fonction de récupération du panier courant

feature/export_comptable
Guillaume před 4 roky
rodič
revize
f8c8197980
2 změnil soubory, kde provedl 21 přidání a 2 odebrání
  1. +18
    -0
      ShopBundle/Repository/OrderShopRepository.php
  2. +3
    -2
      ShopBundle/Services/OrderUtils.php

+ 18
- 0
ShopBundle/Repository/OrderShopRepository.php Zobrazit soubor

@@ -18,4 +18,22 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
return OrderShopInterface::class;
}

public function findCurrent($params)
{
$query = $this->createQueryBuilder('e') ;

if(isset($params['user'])) {
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
}

if(isset($params['visitor'])) {
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ;
}

$query->leftJoin('e.orderStatusHistories', 'orderStatusHistories')
->andWhere('SIZE(e.orderStatusHistories) = 0') ;

return $query->getQuery()->getOneOrNullResult() ;
}

}

+ 3
- 2
ShopBundle/Services/OrderUtils.php Zobrazit soubor

@@ -6,6 +6,7 @@ use App\Entity\OrderProductReductionCatalog;
use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Symfony\Component\Security\Core\Security;

@@ -26,7 +27,7 @@ class OrderUtils
$this->security = $security;
$this->userUtils = $userUtils;
$this->merchantUtils = $merchantUtils;
$this->orderShopRepo = $this->em->getRepository(OrderShop::class);
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName());
$this->priceUtils = $priceUtils ;
$this->productFamilyUtils = $productFamilyUtils ;
}
@@ -46,7 +47,7 @@ class OrderUtils
$paramsSearchOrderShop['visitor'] = $visitor;
}

$orderShop = $this->orderShopRepo->findOneBy($paramsSearchOrderShop);
$orderShop = $this->orderShopRepo->findCurrent($paramsSearchOrderShop);

if (!$orderShop) {
$orderShop = $this->createOrderShop([

Načítá se…
Zrušit
Uložit