Skip to content

Commit bce3a4a

Browse files
authored
Merge pull request #1 from landofcoder/check-value-is-array
return string when option value is array
2 parents 5b3c8c7 + 1c2c692 commit bce3a4a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Model/Resolver/DataProvider/Attributes.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function getAdditionalAttributesBySku($sku)
6161
$data['id'] = $attribute->getId();
6262
$data['code'] = $attribute->getAttributeCode();
6363
$data['label'] = $attribute->getStoreLabel();
64-
$data['value'] = $product->getAttributeText($attribute->getAttributeCode());
64+
$attributeValue = $product->getAttributeText($attribute->getAttributeCode());
65+
$data['value'] = is_array($attributeValue) ? implode(", ", $attributeValue) : $attributeValue;
6566
if (!in_array(null, $data, true) && !in_array(false, $data, true)) {
6667
$additionalAttributes[] = $data;
6768
}
@@ -86,9 +87,11 @@ public function getVisibleAttributes()
8687
$optionData = [];
8788
foreach ($options as $option) {
8889
if (!($option->getValue() == null) || !($option->getLabel() == " ")) {
90+
$optionValue = $option->getValue();
91+
$optionValue = is_array($optionValue) ? implode(", ", $optionValue) : $optionValue;
8992
$optionData[] = [
9093
'label' => $option->getLabel(),
91-
'value' => $option->getValue(),
94+
'value' => $optionValue,
9295
];
9396
}
9497
}

0 commit comments

Comments
 (0)