Skip to content

Commit 605fc08

Browse files
committed
Fix recommendations for configurables
1 parent 192f22d commit 605fc08

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Model/Client/Request/Recommendations/ProductRequest.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public function getProduct()
3333
*/
3434
public function setProduct(Product $product)
3535
{
36-
if ($this->config->isGroupedProductsEnabled() && $product->getTypeId() === 'configurable') {
36+
$this->product = $product;
3737

38+
if ($this->config->isGroupedProductsEnabled() && $product->getTypeId() === 'configurable') {
39+
$this->product = $this->getSimpleProduct($product);
3840
}
3941

40-
$this->product = $product;
4142
return $this;
4243
}
4344

@@ -67,4 +68,14 @@ public function getPathSuffix()
6768

6869
return '/' . $productTweakwiseId . parent::getPathSuffix();
6970
}
71+
72+
private function getSimpleProduct(Product $product)
73+
{
74+
$children = $product->getTypeInstance()->getUsedProducts($product);
75+
foreach ($children as $child) {
76+
if ($child->isSaleable() && $child->getTypeId() === 'simple') {
77+
return $child;
78+
}
79+
}
80+
}
7081
}

0 commit comments

Comments
 (0)