I am using magento 2.3.2. My site takes too much to load. I enabled flat catalog category and Flat catalog product. See https://prnt.sc/pgr3xu. But on site when i click on any product it gives me error "Invalid argument supplied for foreach() in /var/www/html/ihouzit/app/code/Mageplaza/Search/Helper/Data.php on line 345" See https://prnt.sc/pgr3zx What can be the issue.
Getting error from this function
protected function getCategoryOptions($category, &$options, $level, $htmlPrefix = '')
{
if ($level <= 0) {
return $this;
}
$level--;
$options[$category->getId()] = $htmlPrefix . $category->getName();
$htmlPrefix .= '- ';
foreach ($this->getChildCategories($category) as $childCategory) {
$this->getCategoryOptions($childCategory, $options, $level, $htmlPrefix);
}
return $this;
}
php bin/magento indexer:reindex
app/code/Mageplaza/Search/Helper/Data.php
where you are getting this error.