diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php
index 55bf0c89..723c0af2 100644
--- a/Classes/Controller/ProductController.php
+++ b/Classes/Controller/ProductController.php
@@ -185,7 +185,7 @@ public function showAction(Product $product = null): ResponseInterface
{
if ((int)$GLOBALS['TSFE']->page['doktype'] === 183) {
$productUid = (int)$GLOBALS['TSFE']->page['cart_products_product'];
- $product = $this->productRepository->findByUid($productUid);
+ $product = $this->productRepository->findByUid($productUid);
}
$this->view->assign('product', $product);
@@ -203,8 +203,11 @@ public function showFormAction(Product $product = null): ResponseInterface
$product = $this->getProduct();
}
+ $detailLinkData = $this->getDetailLinkData($this->request);
+
$this->view->assign('product', $product);
$this->view->assign('cartSettings', $this->cartConfiguration['settings']);
+ $this->view->assign('detailLinkData', $detailLinkData);
$this->assignCurrencyTranslationData();
return $this->htmlResponse();
@@ -342,4 +345,33 @@ protected function restoreSession(): void
$this->cart = $this->cartUtility->getNewCart($this->cartConfiguration);
$this->sessionHandler->writeCart($this->cartConfiguration['settings']['cart']['pid'], $this->cart);
}
+
+ private function getDetailLinkData(Request $request): array
+ {
+ $frontendController = $request->getAttribute('frontend.controller');
+ $detailPageUid = $frontendController->getRequestedId();
+
+ $requestArguments = $frontendController->getPageArguments()->getArguments();
+
+ $pluginNamespace = preg_grep('/tx_cartproducts_.*/', array_keys($requestArguments));
+ $pluginNamespace = array_shift($pluginNamespace);
+
+ if (!$pluginNamespace) {
+ return [
+ 'uid' => $detailPageUid,
+ ];
+ }
+
+ $pluginArguments = $requestArguments[$pluginNamespace];
+ $controller = $pluginArguments['controller'];
+ $action = $pluginArguments['action'];
+ $pluginName = preg_replace('/tx_cartproducts_/', '', $pluginNamespace);
+
+ return [
+ 'uid' => $detailPageUid,
+ 'pluginName' => $pluginName,
+ 'controller' => $controller,
+ 'action' => $action,
+ ];
+ }
}
diff --git a/Classes/EventListener/Create/CreateCartProduct.php b/Classes/EventListener/Create/CreateCartProduct.php
index eb92210b..f1b75bf5 100644
--- a/Classes/EventListener/Create/CreateCartProduct.php
+++ b/Classes/EventListener/Create/CreateCartProduct.php
@@ -11,11 +11,13 @@
* LICENSE file that was distributed with this source code.
*/
+use Extcode\Cart\Domain\Model\Cart\DetailPageLinkFactoryInterface;
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent;
class CreateCartProduct
{
+ public function __construct(protected DetailPageLinkFactoryInterface $detailPageLinkFactory) {}
public function __invoke(RetrieveProductsFromRequestEvent $event): void
{
$request = $event->getRequest();
@@ -53,6 +55,17 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void
$cartProduct->setIsVirtualProduct(true);
}
+ if ($request->getArgument('detailPageUid')) {
+ $detailPageLink = $this->detailPageLinkFactory->getDetailPageLink(
+ (int)$request->getArgument('detailPageUid'),
+ 'cartproducts',
+ $request->getArgument('detailPagePluginName'),
+ $request->getArgument('detailPageController'),
+ $request->getArgument('detailPageAction')
+ );
+ $cartProduct->setDetailPageLink($detailPageLink);
+ }
+
$event->setCartProduct($cartProduct);
}
}
diff --git a/Resources/Private/Partials/Product/CartForm.html b/Resources/Private/Partials/Product/CartForm.html
index 2765279f..cb8a0377 100644
--- a/Resources/Private/Partials/Product/CartForm.html
+++ b/Resources/Private/Partials/Product/CartForm.html
@@ -17,6 +17,10 @@
additionalAttributes="{data-ajax: '{f:if(condition: \'{settings.addToCartByAjax}\', then: \'1\', else: \'0\')}', data-type: 'slot', data-id: '{slot.uid}'}">
+
+
+
+
diff --git a/Resources/Private/Templates/Product/ShowForm.html b/Resources/Private/Templates/Product/ShowForm.html
index 6705bee8..bb4e216d 100644
--- a/Resources/Private/Templates/Product/ShowForm.html
+++ b/Resources/Private/Templates/Product/ShowForm.html
@@ -6,7 +6,8 @@
-
+
@@ -18,4 +19,4 @@
-