Skip to content

Commit 99ded4d

Browse files
committed
Implement requested changes
1 parent ca434e9 commit 99ded4d

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Model/Client/Request/Recommendations/ProductRequest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ public function getPathSuffix()
6969
return '/' . $productTweakwiseId . parent::getPathSuffix();
7070
}
7171

72-
private function getSimpleProduct(Product $product)
72+
/**
73+
* @param Product $product
74+
* @return Product
75+
*/
76+
private function getSimpleProduct(Product $product): Product
7377
{
7478
$children = $product->getTypeInstance()->getUsedProducts($product);
7579
foreach ($children as $child) {
76-
if ($child->isSaleable() && $child->getTypeId() === 'simple') {
80+
if ($child->isSaleable() && $child->getTypeId() === Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) {
7781
return $child;
7882
}
7983
}

Model/Client/Response/RecommendationsResponse.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@
1717

1818
class RecommendationsResponse extends Response
1919
{
20+
/**
21+
* @var bool
22+
*/
2023
private bool $proccessedGroupedProducts = false;
2124

25+
/**
26+
* RecommendationsResponse constructor.
27+
*
28+
* @param Helper $helper
29+
* @param Request $request
30+
* @param Config $config
31+
* @param array|null $data
32+
*/
2233
public function __construct(
2334
Helper $helper,
2435
Request $request,
@@ -56,7 +67,7 @@ public function setRecommendation(array $recommendation)
5667
public function getItems(): array
5768
{
5869
if ($this->config->isGroupedProductsEnabled() && !$this->proccessedGroupedProducts) {
59-
//manually group items since recommendations doesn't have an grouped call yet.
70+
// Manually group items since recommendations doesn't have a grouped call yet.
6071
$items = parent::getItems();
6172
$groups = [];
6273
if (empty($items)) {

Model/Client/Type/ItemType.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ public function getUrl()
118118
return (string) $this->getDataValue('url');
119119
}
120120

121-
public function getGroupCodeFromAttributes()
121+
/**
122+
* @return string
123+
*/
124+
public function getGroupCodeFromAttributes(): string
122125
{
123126
$attributes = $this->getDataValue('attributes');
124127

@@ -132,7 +135,7 @@ public function getGroupCodeFromAttributes()
132135
$attribute['name'] === 'groupcode' &&
133136
isset($attribute['values']['value'])
134137
) {
135-
return (string)($attribute['values']['value']);
138+
return (string)$attribute['values']['value'];
136139
}
137140
}
138141

0 commit comments

Comments
 (0)