diff --git a/src/CoreShop/Bundle/CoreBundle/EventListener/CartBlamerListener.php b/src/CoreShop/Bundle/CoreBundle/EventListener/CartBlamerListener.php index e1f5e6a33d..d603ba8c2e 100755 --- a/src/CoreShop/Bundle/CoreBundle/EventListener/CartBlamerListener.php +++ b/src/CoreShop/Bundle/CoreBundle/EventListener/CartBlamerListener.php @@ -32,14 +32,25 @@ final class CartBlamerListener */ private $cartContext; + /** + * @var CartManagerInterface + */ + private $cartManager; + /** * @param CartProcessorInterface $cartProcessor * @param CartContextInterface $cartContext + * @param CartManagerInterface $cartManager */ - public function __construct(CartProcessorInterface $cartProcessor, CartContextInterface $cartContext) + public function __construct( + CartProcessorInterface $cartProcessor, + CartContextInterface $cartContext, + CartManagerInterface $cartManager + ) { $this->cartProcessor = $cartProcessor; $this->cartContext = $cartContext; + $this->cartManager = $cartManager; } /** @@ -91,6 +102,13 @@ private function blame(CustomerInterface $user) } $this->cartProcessor->process($cart); + + if ($cart->getId()) { + $this->cartManager->persistCart($cart); + return; + } + + $this->cartProcessor->process($cart); } /** diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/listeners.yml b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/listeners.yml index c9c00fd86a..b4995fe38a 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/listeners.yml +++ b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/listeners.yml @@ -7,6 +7,7 @@ services: arguments: - '@coreshop.cart_processor' - '@coreshop.context.cart' + - '@coreshop.cart.manager' tags: - { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin } - { name: kernel.event_listener, event: coreshop.customer.register, method: onRegisterEvent }