Exception #0 (Exception): Warning: explode() expects parameter 2 to be string, array given in /home/user/public_html/app/code/Mageplaza/LayeredNavigation/Plugin/Model/Adapter/Preprocessor.php on line 92
the code
if (($filter->getField() === 'category_ids')) {
$filterValue = implode(',', array_map([$this, 'validateCatIds'], explode(',', $filter->getValue())));
2 Answers 2
Check the value for the $filter->getValue() using $filter->getValue()??''.
Your code should be:
$filterValue = implode(',', array_map([$this, 'validateCatIds'], explode(',', $filter->getValue()??'')));
answered Sep 29, 2024 at 13:46
Please modify your code like below
if (($filter->getField() === 'category_ids')) {
$value = $filter->getValue();
if (is_array($value)) {
$filterValue = implode(',', array_map([$this, 'validateCatIds'], $value));
} else {
$filterValue = implode(',', array_map([$this, 'validateCatIds'], explode(',', $value)));
}
}
answered Oct 4, 2024 at 11:25
default