From d796ffb0f87a162a501733307ecb18c5459c5b2b Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 2 Sep 2024 11:56:16 +0200 Subject: [PATCH] NTR: fix container --- src/Checkout/Cart/ExpressCartItemAddRoute.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Checkout/Cart/ExpressCartItemAddRoute.php b/src/Checkout/Cart/ExpressCartItemAddRoute.php index d83159587..ba1e2bd59 100644 --- a/src/Checkout/Cart/ExpressCartItemAddRoute.php +++ b/src/Checkout/Cart/ExpressCartItemAddRoute.php @@ -21,10 +21,10 @@ class ExpressCartItemAddRoute extends AbstractCartItemAddRoute private $cartItemAddRoute; /** - * @var CartBackupService + * @var ContainerInterface */ + private $container; - private $cartBackupService; /** * @var CartServiceInterface */ @@ -33,7 +33,7 @@ class ExpressCartItemAddRoute extends AbstractCartItemAddRoute public function __construct(AbstractCartItemAddRoute $cartItemAddRoute, ContainerInterface $container, CartServiceInterface $cartService) { $this->cartItemAddRoute = $cartItemAddRoute; - $this->cartBackupService = $container->get(CartBackupService::class); + $this->container = $container; $this->cartService = $cartService; } @@ -58,9 +58,9 @@ public function add(Request $request, Cart $cart, SalesChannelContext $context, if ($isExpressCheckout === false) { return $this->getDecorated()->add($request, $cart, $context, $items); } - - if (!$this->cartBackupService->isBackupExisting($context)) { - $this->cartBackupService->backupCart($context); + $cartBackupService = $this->container->get(CartBackupService::class); //Shopware 6.4 have circular injection, we have to use contaier + if (!$cartBackupService->isBackupExisting($context)) { + $cartBackupService->backupCart($context); } $cart = $this->cartService->getCalculatedMainCart($context);