$this->processProducts($entity); | $this->processProducts($entity); | ||||
$this->processPrice($entity); | $this->processPrice($entity); | ||||
} | } | ||||
parent::updateEntity($entity); | parent::updateEntity($entity); | ||||
$this->orderUtils->updatePriceByProductFamily($entity); | |||||
} | } | ||||
public function persistProductFamilyEntity($entity, $newForm) | public function persistProductFamilyEntity($entity, $newForm) |
$form->handleRequest($request); | $form->handleRequest($request); | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$orderShop = $this->orderUtils->getCartCurrent() ; | |||||
$orderShop = $this->orderUtils->getCartCurrent(true) ; | |||||
$data = $form->getData() ; | $data = $form->getData() ; | ||||
foreach($data as $orderProduct) { | foreach($data as $orderProduct) { | ||||
if($orderProduct instanceof OrderProductInterface) { | if($orderProduct instanceof OrderProductInterface) { |
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | use Lc\ShopBundle\Context\DefaultRepositoryInterface; | ||||
use Lc\ShopBundle\Context\OrderProductInterface; | use Lc\ShopBundle\Context\OrderProductInterface; | ||||
use Lc\ShopBundle\Model\OrderStatus; | |||||
/** | /** | ||||
* @method OrderProductInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method OrderProductInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
return OrderProductInterface::class; | return OrderProductInterface::class; | ||||
} | } | ||||
public function findOrderProductsInCartsByProduct($product){ | |||||
$qb = $this->createQueryBuilder('e'); | |||||
$qb->andWhere('e.product = :product'); | |||||
$qb->andWhere('e.redelivery = false OR e.redelivery IS NULL'); | |||||
$qb->setParameter('product', $product); | |||||
$qb->leftJoin('e.orderShop', 'orderShop'); | |||||
$qb->andWhere('orderShop.merchant = :currentMerchant'); | |||||
$qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()); | |||||
$qb->leftJoin('orderShop.orderStatus', 'orderStatus'); | |||||
$qb->andWhere('orderStatus.alias IN (:alias)'); | |||||
$qb->setParameter('alias',OrderStatus::ALIAS_CART); | |||||
return $qb->getQuery()->getResult(); | |||||
} | |||||
} | } |
public function addOrderProduct($orderShop, $orderProductAdd, $persist = true) | public function addOrderProduct($orderShop, $orderProductAdd, $persist = true) | ||||
{ | { | ||||
$return = false; | $return = false; | ||||
$user = $this->security->getUser(); | $user = $this->security->getUser(); |
} | } | ||||
public function getCartCurrent() | |||||
public function getCartCurrent($createIfNotExist = false) | |||||
{ | { | ||||
$paramsSearchOrderShop = []; | $paramsSearchOrderShop = []; | ||||
} | } | ||||
} | } | ||||
if($createIfNotExist && !$orderShop) { | |||||
$orderShop = $this->createOrderShop([ | |||||
'user' => $user, | |||||
'visitor' => $visitor, | |||||
'merchant' => $this->merchantUtils->getMerchantCurrent() | |||||
]); | |||||
} | |||||
return $orderShop; | return $orderShop; | ||||
} | } | ||||