Skip to content

Commit

Permalink
Feature #2437 Allow indexing 0 and false values
Browse files Browse the repository at this point in the history
  • Loading branch information
rbayet committed Mar 13, 2022
1 parent c23bac5 commit 6db3c23
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/module-elasticsuite-catalog/Helper/AbstractAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public function prepareIndexValue(AttributeInterface $attribute, $storeId, $valu
}

$value = array_map($this->attributeMappers[$mapperKey], $value);
$value = array_filter($value);
// Filter empty values while keeping "0" (int or float) and "false" value.
$value = array_filter($value, function ($v) { return (($v === false) || strlen($v)); });
$value = array_values($value);
$values[$attributeCode] = $value;

Expand Down Expand Up @@ -253,7 +254,10 @@ public function getIndexOptionText(AttributeInterface $attribute, $storeId, $opt
if (!isset($this->attributeOptionTextCache[$storeId][$attributeId][$optionId])) {
$optionValue = $attribute->getSource()->getIndexOptionText($optionId);
if ($this->getFieldType($attribute) == FieldInterface::FIELD_TYPE_BOOLEAN) {
$optionValue = $attribute->getStoreLabel($storeId);
$optionValue = null;
if ($optionId == \Magento\Eav\Model\Entity\Attribute\Source\Boolean::VALUE_YES) {
$optionValue = $attribute->getStoreLabel($storeId);
}
}
$this->attributeOptionTextCache[$storeId][$attributeId][$optionId] = $optionValue;
}
Expand Down

0 comments on commit 6db3c23

Please sign in to comment.