Skip to content

Commit

Permalink
Merge pull request #1779 from dgtls/issue/fix-load-latest-cart
Browse files Browse the repository at this point in the history
[Cart] fix existing cart initalization on customer login
  • Loading branch information
dpfaffenbauer authored Nov 15, 2021
2 parents 7626e21 + 5242e52 commit 2cf7908
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,13 @@ public function findForCustomer(CustomerInterface $customer): array
return $carts;
}

public function findNamedForCustomer(CustomerInterface $customer, $name): ?OrderInterface
{
$list = $this->getList();
$list->setCondition('customer__id = ? AND name = ? AND order__id is null', [$customer->getId(), $name]);
$list->load();

$objects = $list->getObjects();

if (count($objects) === 1 && $objects[0] instanceof OrderInterface) {
return $objects[0];
}

return null;
}

public function findLatestByStoreAndCustomer(StoreInterface $store, CustomerInterface $customer): ?OrderInterface
{
$list = $this->getList();
$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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ interface CartRepositoryInterface extends PimcoreRepositoryInterface
*/
public function findForCustomer(CustomerInterface $customer): array;

/**
* @param string $name
*/
public function findNamedForCustomer(CustomerInterface $customer, $name): ?OrderInterface;

public function findLatestByStoreAndCustomer(StoreInterface $store, CustomerInterface $customer): ?OrderInterface;

/**
Expand Down

0 comments on commit 2cf7908

Please sign in to comment.