未捕获的TypeError:传递给Mage_Core_Model_Store_Group :: setWebsite()的参数1必须是Mage_Core_Model_Website的一个实例,给出null

时间:2017-10-17 08:23:44

标签: php magento magento-1.9 php-7 magento-1.9.3

Magneto 1.9.3迁移到具有php版本7.0.23的新服务器

我将我的magento网站服务器更新为现在的7.0.23的新php版本,之前它工作正常,但现在给出了问题

致命错误:未捕获的TypeError:传递给Mage_Core_Model_Store_Group :: setWebsite()的参数1必须是Mage_Core_Model_Website的一个实例,null给定,在

中调用

enter image description here

我尝试了用于php 7的inchoo补丁,但没有任何效果。 https://github.com/Inchoo/Inchoo_PHP7

3 个答案:

答案 0 :(得分:1)

我尝试了@cd001

提到的上述方法

首先我更新了文件app/code/core/Mage/Core/Model/Store/Group.php 在那我只是替换下面的行

public function setWebsite(Mage_Core_Model_Website $website)

public function setWebsite(Mage_Core_Model_Website $website = null)

然后我又出现了另一个错误

Fatal error: Uncaught Error: Function name must be a string in 
app\code\core\Mage\Core\Model\Layout.php:555 Stack trace: #0 
app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput() #1 
app\code\core\Mage\Cms\Helper\Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout() #2 
app\code\core\Mage\Cms\Helper\Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home') #3 
app\code\core\Mage\Cms\controllers\IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home') #4 
app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Cms_IndexController->indexAction() #5 
app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index') #6 
app\code\core\Mage\Core\Model\Layout.php on line 555

为此我更新了文件app/code/core/Mage/Core/Model/Layout.php

因为我替换了下面的行

$out .= $this->getBlock($callback[0])->$callback[1]();

$out .= $this->getBlock($callback[0])->{$callback[1]}();

一切正常......

答案 1 :(得分:0)

看起来当前版本的Inchoo_PHP7仅适用于最新版本的Magento。阅读他们的发行说明https://github.com/Inchoo/Inchoo_PHP7/releases

我的旧版Inchoo_PHP7包含您上面提到的文件的所有修复程序。像这样......

<core>
    <rewrite>
        <layout>Inchoo_PHP7_Model_Layout</layout>
    </rewrite>
</core>

答案 2 :(得分:0)

使用SQL

SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

AND

清除缓存! (将所有内容删除在magento / var / chache /中)