Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 25bb776

Browse files
committed
MAGETWO-57006: [Forwardport] Performance improvement on Catalog Fulltext indexer
1 parent fe79512 commit 25bb776

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
598598
if (false !== $value) {
599599
$optionValue = $this->getAttributeOptionValue($attributeId, $valueId, $storeId);
600600
if (null === $optionValue) {
601-
$value = preg_replace('/\s+/iu', ' ', trim(strip_tags($value)));
601+
$value = $this->filterAttributeValue($value);
602602
} else {
603603
$value = implode($this->separator, array_filter([$value, $optionValue]));
604604
}
@@ -628,11 +628,25 @@ private function getAttributeOptionValue($attributeId, $valueId, $storeId)
628628
$attribute->setStoreId($storeId);
629629
$options = $attribute->getSource()->toOptionArray();
630630
$this->attributeOptions[$optionKey] = array_column($options, 'label', 'value');
631+
$this->attributeOptions[$optionKey] = array_map(function ($value) {
632+
return $this->filterAttributeValue($value);
633+
}, $this->attributeOptions[$optionKey]);
631634
} else {
632635
$this->attributeOptions[$optionKey] = null;
633636
}
634637
}
635638

636639
return $this->attributeOptions[$optionKey][$valueId] ?? null;
637640
}
641+
642+
/**
643+
* Remove whitespaces and tags from attribute value
644+
*
645+
* @param string $value
646+
* @return string
647+
*/
648+
private function filterAttributeValue($value)
649+
{
650+
return preg_replace('/\s+/iu', ' ', trim(strip_tags($value)));
651+
}
638652
}

0 commit comments

Comments
 (0)