From 25fa17aa2cf6e1c8e12d6504d5fd89b88ff9eabb Mon Sep 17 00:00:00 2001 From: rintisch Date: Wed, 5 Jun 2024 08:32:46 +0200 Subject: [PATCH 1/4] [FEATURE] Enable link to detail view Further adaptions are needed in product extensions. Fixes: #522 --- Classes/Domain/Model/Cart/Product.php | 16 +++++++++ .../Cart/ProductForm/ProductList.html | 34 +++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Model/Cart/Product.php b/Classes/Domain/Model/Cart/Product.php index c77e4c82..2a6fa76e 100644 --- a/Classes/Domain/Model/Cart/Product.php +++ b/Classes/Domain/Model/Cart/Product.php @@ -69,6 +69,7 @@ public function __construct( protected TaxClass $taxClass, protected int $quantity, protected bool $isNetPrice = false, + protected array $detailViewParameter = [], FeVariant $feVariant = null ) { if ($feVariant) { @@ -698,4 +699,19 @@ public function setHandleStockInVariants(bool $handleStockInVariants): void { $this->handleStockInVariants = $handleStockInVariants; } + + public function getDetailViewParameter(): array + { + return $this->detailViewParameter; + } + + public function setDetailViewParameter(array $detailViewParameter): void + { + $this->detailViewParameter = $detailViewParameter; + } + + public function addDetailViewParameter(string $key, int|string $value): void + { + $this->detailViewParameter[$key] = $value; + } } diff --git a/Resources/Private/Partials/Cart/ProductForm/ProductList.html b/Resources/Private/Partials/Cart/ProductForm/ProductList.html index 30ffbc56..b53dca66 100644 --- a/Resources/Private/Partials/Cart/ProductForm/ProductList.html +++ b/Resources/Private/Partials/Cart/ProductForm/ProductList.html @@ -6,7 +6,21 @@
- {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} + + + + {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} + + + + {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} + +

@@ -59,7 +73,23 @@   -

{variant.title}
+
+ + + + {variant.title} + + + + {variant.title} + + +

: {variant.completeSku} From 611d0276afa02c9835e8971de3f4ae1d60f442ab Mon Sep 17 00:00:00 2001 From: rintisch Date: Wed, 19 Jun 2024 07:18:20 +0200 Subject: [PATCH 2/4] [TASK] Improve naming and adapt parameter structure --- Classes/Domain/Model/Cart/Product.php | 15 +++++++------- .../Cart/ProductForm/ProductList.html | 20 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Classes/Domain/Model/Cart/Product.php b/Classes/Domain/Model/Cart/Product.php index 2a6fa76e..e9ddcbce 100644 --- a/Classes/Domain/Model/Cart/Product.php +++ b/Classes/Domain/Model/Cart/Product.php @@ -60,6 +60,8 @@ class Product */ protected bool $handleStockInVariants = false; + protected array $detailPageParameter = []; + public function __construct( protected string $productType, protected int $productId, @@ -69,7 +71,6 @@ public function __construct( protected TaxClass $taxClass, protected int $quantity, protected bool $isNetPrice = false, - protected array $detailViewParameter = [], FeVariant $feVariant = null ) { if ($feVariant) { @@ -700,18 +701,18 @@ public function setHandleStockInVariants(bool $handleStockInVariants): void $this->handleStockInVariants = $handleStockInVariants; } - public function getDetailViewParameter(): array + public function getDetailPageParameter(): array { - return $this->detailViewParameter; + return $this->detailPageParameter; } - public function setDetailViewParameter(array $detailViewParameter): void + public function setDetailPageParameter(array $detailPageParameter): void { - $this->detailViewParameter = $detailViewParameter; + $this->detailPageParameter = $detailPageParameter; } - public function addDetailViewParameter(string $key, int|string $value): void + public function addDetailPageParameter(string $key, int|string $value): void { - $this->detailViewParameter[$key] = $value; + $this->detailPageParameter[$key] = $value; } } diff --git a/Resources/Private/Partials/Cart/ProductForm/ProductList.html b/Resources/Private/Partials/Cart/ProductForm/ProductList.html index b53dca66..a40ae0f6 100644 --- a/Resources/Private/Partials/Cart/ProductForm/ProductList.html +++ b/Resources/Private/Partials/Cart/ProductForm/ProductList.html @@ -6,13 +6,13 @@

- + {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} @@ -74,13 +74,13 @@  
- + {variant.title} From 3e848a55530677befff5505c6c9a17c915131896 Mon Sep 17 00:00:00 2001 From: rintisch Date: Thu, 20 Jun 2024 06:26:55 +0200 Subject: [PATCH 3/4] [TASK] Introduce `DetailPageLink` object + factory --- Classes/Domain/Model/Cart/DetailPageLink.php | 42 +++++++++++++++++++ .../Model/Cart/DetailPageLinkFactory.php | 27 ++++++++++++ .../Cart/DetailPageLinkFactoryInterface.php | 22 ++++++++++ Classes/Domain/Model/Cart/Product.php | 15 +++---- .../Cart/ProductForm/ProductList.html | 18 ++++---- 5 files changed, 105 insertions(+), 19 deletions(-) create mode 100644 Classes/Domain/Model/Cart/DetailPageLink.php create mode 100644 Classes/Domain/Model/Cart/DetailPageLinkFactory.php create mode 100644 Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php diff --git a/Classes/Domain/Model/Cart/DetailPageLink.php b/Classes/Domain/Model/Cart/DetailPageLink.php new file mode 100644 index 00000000..cb2c2322 --- /dev/null +++ b/Classes/Domain/Model/Cart/DetailPageLink.php @@ -0,0 +1,42 @@ +pageUid; + } + + public function getExtensionName(): string + { + return $this->extensionName; + } + + public function getPluginName(): string + { + return $this->pluginName; + } + + public function getController(): string + { + return $this->controller; + } +} diff --git a/Classes/Domain/Model/Cart/DetailPageLinkFactory.php b/Classes/Domain/Model/Cart/DetailPageLinkFactory.php new file mode 100644 index 00000000..d4ec873c --- /dev/null +++ b/Classes/Domain/Model/Cart/DetailPageLinkFactory.php @@ -0,0 +1,27 @@ + 0) { + return new DetailPageLink($detailPageUid, $extensionName, $pluginName, $controller); + } + return null; + } +} diff --git a/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php b/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php new file mode 100644 index 00000000..1ef8299b --- /dev/null +++ b/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php @@ -0,0 +1,22 @@ +handleStockInVariants = $handleStockInVariants; } - public function getDetailPageParameter(): array + public function getDetailPageLink(): DetailPageLink { - return $this->detailPageParameter; + return $this->detailPageLink; } - public function setDetailPageParameter(array $detailPageParameter): void + public function setDetailPageLink(DetailPageLink $detailPageLink): void { - $this->detailPageParameter = $detailPageParameter; - } - - public function addDetailPageParameter(string $key, int|string $value): void - { - $this->detailPageParameter[$key] = $value; + $this->detailPageLink = $detailPageLink; } } diff --git a/Resources/Private/Partials/Cart/ProductForm/ProductList.html b/Resources/Private/Partials/Cart/ProductForm/ProductList.html index a40ae0f6..a949d110 100644 --- a/Resources/Private/Partials/Cart/ProductForm/ProductList.html +++ b/Resources/Private/Partials/Cart/ProductForm/ProductList.html @@ -6,13 +6,13 @@
- + {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} @@ -77,10 +77,10 @@ {variant.title} From 3a4d0f2d2e578c92037fabed78df8c1a24810f7d Mon Sep 17 00:00:00 2001 From: rintisch Date: Thu, 10 Oct 2024 15:47:02 +0200 Subject: [PATCH 4/4] [TASK] Adaptions after split of ProductPlugin After the migration of switchableControllerActions in EXT:cart_products the pluginName can differ which needs to be considered. This makes the approach more generic. --- Classes/Domain/Model/Cart/DetailPageLink.php | 15 ++++- .../Model/Cart/DetailPageLinkFactory.php | 5 +- .../Cart/DetailPageLinkFactoryInterface.php | 3 +- .../Cart/ProductForm/ProductList.html | 65 ++++++++++--------- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/Classes/Domain/Model/Cart/DetailPageLink.php b/Classes/Domain/Model/Cart/DetailPageLink.php index cb2c2322..463d171e 100644 --- a/Classes/Domain/Model/Cart/DetailPageLink.php +++ b/Classes/Domain/Model/Cart/DetailPageLink.php @@ -17,7 +17,8 @@ public function __construct( protected int $pageUid, protected string $extensionName = '', protected string $pluginName = '', - protected string $controller = '' + protected string $controller = '', + protected string $action = '', ) {} public function getPageUid(): int @@ -39,4 +40,16 @@ public function getController(): string { return $this->controller; } + public function getAction(): string + { + return $this->action; + } + + public function isActionLink(): bool + { + if ($this->pageUid && $this->extensionName && $this->pluginName && $this->controller && $this->action) { + return true; + } + return false; + } } diff --git a/Classes/Domain/Model/Cart/DetailPageLinkFactory.php b/Classes/Domain/Model/Cart/DetailPageLinkFactory.php index d4ec873c..98ad3a76 100644 --- a/Classes/Domain/Model/Cart/DetailPageLinkFactory.php +++ b/Classes/Domain/Model/Cart/DetailPageLinkFactory.php @@ -17,10 +17,11 @@ public function getDetailPageLink( int $detailPageUid, string $extensionName = '', string $pluginName = '', - string $controller = '' + string $controller = '', + string $action = '', ): ?DetailPageLink { if ($detailPageUid > 0) { - return new DetailPageLink($detailPageUid, $extensionName, $pluginName, $controller); + return new DetailPageLink($detailPageUid, $extensionName, $pluginName, $controller, $action); } return null; } diff --git a/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php b/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php index 1ef8299b..c2e086f5 100644 --- a/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php +++ b/Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php @@ -17,6 +17,7 @@ public function getDetailPageLink( int $detailPageUid, string $extensionName = '', string $pluginName = '', - string $controller = '' + string $controller = '', + string $action = '' ): ?DetailPageLink; } diff --git a/Resources/Private/Partials/Cart/ProductForm/ProductList.html b/Resources/Private/Partials/Cart/ProductForm/ProductList.html index a949d110..f4229470 100644 --- a/Resources/Private/Partials/Cart/ProductForm/ProductList.html +++ b/Resources/Private/Partials/Cart/ProductForm/ProductList.html @@ -2,25 +2,41 @@ xmlns:cart="http://typo3.org/ns/Extcode/Cart/ViewHelpers" data-namespace-typo3-fluid="true"> + + + + + + {linkedTitle} + + + + + {linkedTitle} + + + + + + {linkedTitle} + + + +
- - - - {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} - - - - {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} - - + + {product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')} + +

@@ -74,21 +90,10 @@  

- - - - {variant.title} - - - - {variant.title} - - + + {variant.title} + +