0

我正在为客户创建一个自定义 magento rma 扩展。在我的控制器文件中,当我尝试访问$this->renderLayout();功能时发生以下错误。

Attempt to add an invalid object

#0 D:\wamp\www\magentotest\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(263): Mage::exception('Mage_Eav', 'Attempt to add ...')
#1 D:\wamp\www\magentotest\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(1057): Mage_Eav_Model_Entity_Collection_Abstract->addItem(Object(sengar_Rma_Model_Item))
#2 D:\wamp\www\magentotest\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(871): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false)
#3 D:\wamp\www\magentotest\lib\Varien\Data\Collection.php(741): Mage_Eav_Model_Entity_Collection_Abstract->load()
#4 D:\wamp\www\magentotest\app\design\frontend\base\default\template\rma\return\view.phtml(182): Varien_Data_Collection->getIterator()
#5 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(241): include('D:\wamp\www\mag...')
#6 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('frontend\base\d...')
#7 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#8 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#9 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#10 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(522): Mage_Core_Block_Abstract->_getChildHtml('rma.return.hist...', true)
#11 D:\wamp\www\magentotest\app\code\core\Mage\Page\Block\Html\Wrapper.php(52): Mage_Core_Block_Abstract->getChildHtml('', true, true)
#12 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Page_Block_Html_Wrapper->_toHtml()
#13 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#14 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Core_Block_Text_List->_toHtml()
#15 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#16 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#17 D:\wamp\www\magentotest\app\design\frontend\base\default\template\page\2columns-left.phtml(48): Mage_Core_Block_Abstract->getChildHtml('content')
#18 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(241): include('D:\wamp\www\mag...')
#19 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('frontend\base\d...')
#20 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#21 D:\wamp\www\magentotest\app\code\core\Mage\Core\Block\Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#22 D:\wamp\www\magentotest\app\code\core\Mage\Core\Model\Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#23 D:\wamp\www\magentotest\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput()
#24 D:\wamp\www\magentotest\app\code\local\Sengar\Rma\controllers\ReturnController.php(227): Mage_Core_Controller_Varien_Action->renderLayout()
#25 D:\wamp\www\magentotest\app\code\core\Mage\Core\Controller\Varien\Action.php(419): sengar_Rma_ReturnController->viewAction()
#26 D:\wamp\www\magentotest\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#27 D:\wamp\www\magentotest\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#28 D:\wamp\www\magentotest\app\code\core\Mage\Core\Model\App.php(354enter code here): Mage_Core_Controller_Varien_Front->dispatch()
#29 D:\wamp\www\magentotest\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#30 D:\wamp\www\magentotest\index.php(87): Mage::run('', 'store')
#31 {main}

该功能目前看起来像:

$this->loadLayout(); 
$this->_initLayoutMessages('catalog/session'); 
$this->getLayout() ->getBlock('head') ->setTitle(Mage::helper('sengar_rma')->__('RMA #%s', Mage::registry('current_rma')->getIncrementId())); 
$this->renderLayout();
4

1 回答 1

0

在文件中:frontend\base\default\template\rma\return\view.phtml,第 182 行您正在创建集合,这会导致错误 - 它与 renderLayout() 无关,导致 app\code\ 引发错误core\Mage\Eav\Model\Entity\Collection\Abstract.php:263。(集合不应该在视图中加载,而是在块中) - 修复该行和集合获取。

于 2013-03-08T09:55:30.170 回答