Skip to content

Commit

Permalink
[FEATURE] Enable link to detail view
Browse files Browse the repository at this point in the history
Further adaptions are needed in product
extensions.

Fixes: #522
  • Loading branch information
rintisch committed Jun 5, 2024
1 parent 6fa0caf commit 3e2353c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
21 changes: 20 additions & 1 deletion Classes/Domain/Model/Cart/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Product
*/
protected bool $handleStockInVariants = false;

protected array $detailViewParameter = [];

public function __construct(
string $productType,
int $productId,
Expand All @@ -85,7 +87,8 @@ public function __construct(
TaxClass $taxClass,
int $quantity,
bool $isNetPrice = false,
FeVariant $feVariant = null
FeVariant $feVariant = null,
array $detailViewParameter = []
) {
$this->productType = $productType;
$this->productId = $productId;
Expand All @@ -95,6 +98,7 @@ public function __construct(
$this->taxClass = $taxClass;
$this->quantity = $quantity;
$this->isNetPrice = $isNetPrice;
$this->detailViewParameter = $detailViewParameter;

if ($feVariant) {
$this->feVariant = $feVariant;
Expand Down Expand Up @@ -729,4 +733,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;
}
}
34 changes: 32 additions & 2 deletions Resources/Private/Partials/Cart/ProductForm/ProductList.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
<tr class="{f:if(condition: product.quantityInRange, then: '', else: 'danger')}">
<td colspan="2" class="col-md-6">
<div class="product-name">
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
<f:if condition="{product.detailViewParameter}">
<f:then>
<f:link.action
pageUid="{product.detailViewParameter.pageUid}"
extensionName="{product.detailViewParameter.extensionName}"
pluginName="{product.detailViewParameter.pluginName}"
controller="{product.detailViewParameter.controller}"
arguments="{product: product.productId}">
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
</f:link.action>
</f:then>
<f:else>
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
</f:else>
</f:if>
</div>
<p>
<f:translate key="tx_cart_domain_model_order_product.sku.short"/>
Expand Down Expand Up @@ -59,7 +73,23 @@
<tr class="{f:if(condition: product.quantityInRange, then: '', else: 'danger')}">
<td class="col-md-1">&nbsp;</td>
<td class="col-md-5">
<div class="product-name">{variant.title}</div>
<div class="product-name">
<f:if condition="{product.detailViewParameter}">
<f:then>
<f:link.action
pageUid="{product.detailViewParameter.pageUid}"
extensionName="{product.detailViewParameter.extensionName}"
pluginName="{product.detailViewParameter.pluginName}"
controller="{product.detailViewParameter.controller}"
arguments="{product: product.productId}">
{variant.title}
</f:link.action>
</f:then>
<f:else>
{variant.title}
</f:else>
</f:if>
</div>
<p>
<f:translate key="tx_cart_domain_model_order_product.sku.short"/>
: {variant.completeSku}
Expand Down

0 comments on commit 3e2353c

Please sign in to comment.