前台或是日志中聘
main.ERROR: Warning: Invalid argument supplied for foreach() in /www/wwwroot/****/app/code/Mageplaza/Search/Helper/Data.php on line 345 []
解决方法
打开文件
app/code/Mageplaza/Search/Helper/Data.php
修改大约345行从
public function getCategoryTree()
{
$categoriesOptions = [0 => __('All Categories')];
$maxLevel = max(0, (int)$this->getConfigGeneral('category/max_depth')) ?: 2;
$parent = $this->storeManager->getStore()->getRootCategoryId();
$categories = $this->categoryFactory->create()
->getCategories($parent, 1, false, true);
foreach ($categories as $category) {
$this->getCategoryOptions($category, $categoriesOptions, $maxLevel);
}
return $categoriesOptions;
}到
public function getCategoryTree()
{
$categoriesOptions = [0 => __('All Categories')];
$maxLevel = max(0, (int)$this->getConfigGeneral('category/max_depth')) ?: 2;
$parent = $this->storeManager->getStore()->getRootCategoryId();
$categories = $this->categoryFactory->create()
->getCategories($parent, 1, false, true);
if ($this->getChildCategories($category)) {
foreach ($this->getChildCategories($category) as $childCategory) {
$this->getCategoryOptions($childCategory, $options, $level, $htmlPrefix);
}}
return $categoriesOptions;
}