From e258533a5d73958430f121438eecaf3f3aec536d Mon Sep 17 00:00:00 2001 From: Ben Walch Date: Sun, 28 Nov 2021 22:25:29 +0100 Subject: [PATCH] fixes #1699 cart context returns latest cart even if multiple found --- .../Bundle/OrderBundle/Pimcore/Repository/CartRepository.php | 3 +-- .../Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/CartRepository.php b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/CartRepository.php index 7086e64967..7f5888d0eb 100644 --- a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/CartRepository.php +++ b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/CartRepository.php @@ -43,12 +43,11 @@ public function findLatestByStoreAndCustomer(StoreInterface $store, CustomerInte $list->setCondition('customer__id = ? AND store = ? AND order__id is null ', [$customer->getId(), $store->getId()]); $list->setOrderKey('o_creationDate'); $list->setOrder('DESC'); - $list->setLimit(1); $list->load(); $objects = $list->getObjects(); - if (count($objects) === 1 && $objects[0] instanceof OrderInterface) { + if (count($objects) > 0 && $objects[0] instanceof OrderInterface) { return $objects[0]; } diff --git a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php index 0a13bb913e..4be281f2f0 100644 --- a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php +++ b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php @@ -65,7 +65,7 @@ public function findLatestCartByStoreAndCustomer(StoreInterface $store, Customer $objects = $list->getObjects(); - if (count($objects) === 1 && $objects[0] instanceof OrderInterface) { + if (count($objects) > 0 && $objects[0] instanceof OrderInterface) { return $objects[0]; }