M2主题使用Mageplaza Search报错(如porto主题)

作者:admi... 点击数: 0 收藏到会员中心
最后编辑时间: 2021-06-01 11:31

 

前台或是日志中聘

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;
    }


请登录已经激活账号继续浏此文章所有内容!
会员中心

已经有帐号啦 !赶紧同小伙伴们愉快地玩耍吧

立即登录

还没有账号? 马上注册一个新帐户

注册账号
内容说明:
如您需要转载本文请保留以下信息是对作者发文的支持与尊重:

M2主题使用Mageplaza Search报错(如porto主题) 来源于 https://www.magentola.com/news-read-228.html
上一篇:M2后台出现空白,各种异常排查
下一篇:M2.4.2. P1 版本数据库配置要求
相关内容
产品推荐