diff --git a/src/Models/ProductAttributeValue.php b/src/Models/ProductAttributeValue.php index e9b040f..c26285f 100644 --- a/src/Models/ProductAttributeValue.php +++ b/src/Models/ProductAttributeValue.php @@ -48,7 +48,10 @@ class ProductAttributeValue extends DataObject public function getValue() { - if (($value = $this->getField('Value')) === null) { + $value = $this->getField('Value'); + $textValue = $this->getField('TextValue'); + + if ($value === null && $textValue === null) { return null; } @@ -62,8 +65,8 @@ public function getValue() ProductAttributeType::MULTISELECT => DBField::create_field('HTMLText', AttributeParser::MultiSelectParser($this)), ProductAttributeType::PRICE_COLLECTION => DBField::create_field('HTMLText', AttributeParser::PriceCollectionParser($this)), ProductAttributeType::SIMPLESELECT => $attribute->Options()->filter('Code', $value)->first()->Name, - ProductAttributeType::TEXT => DBField::create_field('HTMLText', (string)$value), - ProductAttributeType::TEXTAREA => DBField::create_field('HTMLText', nl2br($this->getField('TextValue') ?? $value)), + ProductAttributeType::TEXT => DBField::create_field('HTMLText', $value ? (string)$value : $textValue), + ProductAttributeType::TEXTAREA => DBField::create_field('HTMLText', $textValue ? nl2br($textValue) : nl2br($value)), default => (string)$value, }; }