Skip to content

Commit

Permalink
Merge pull request #22 from wedevelopnl/fix/get-value-textvalue
Browse files Browse the repository at this point in the history
Fixed TextValue not being taken into account if no Value was entered
  • Loading branch information
erikfrerejean authored Feb 22, 2024
2 parents 8fd1902 + e4dc1b2 commit 4c37d7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Models/ProductAttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
};
}
Expand Down

0 comments on commit 4c37d7e

Please sign in to comment.