@@ -598,7 +598,7 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
598
598
if (false !== $ value ) {
599
599
$ optionValue = $ this ->getAttributeOptionValue ($ attributeId , $ valueId , $ storeId );
600
600
if (null === $ optionValue ) {
601
- $ value = preg_replace ( ' /\s+/iu ' , ' ' , trim ( strip_tags ( $ value)) );
601
+ $ value = $ this -> filterAttributeValue ( $ value );
602
602
} else {
603
603
$ value = implode ($ this ->separator , array_filter ([$ value , $ optionValue ]));
604
604
}
@@ -628,11 +628,25 @@ private function getAttributeOptionValue($attributeId, $valueId, $storeId)
628
628
$ attribute ->setStoreId ($ storeId );
629
629
$ options = $ attribute ->getSource ()->toOptionArray ();
630
630
$ 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 ]);
631
634
} else {
632
635
$ this ->attributeOptions [$ optionKey ] = null ;
633
636
}
634
637
}
635
638
636
639
return $ this ->attributeOptions [$ optionKey ][$ valueId ] ?? null ;
637
640
}
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
+ }
638
652
}
0 commit comments