2012-08-10 134 views
1

我正在使用Magento的商店中工作,但我遇到了一个大问题,但我不知道什么是错误的。当我做点击在管理区“管理客户”,它让我看到以下错误:管理区域内“管理客户”页面上的Magento问题

Fatal error: Call to a member function getBackend() on a non-object in /home/opositivo/developositivo/public_html/pinklemon/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 516 

围绕该行的代码是:

foreach ($attribute as $attributeItem) { 
     if (isset($this->_staticFields[$attributeItem])) { 
       $attrField = sprintf('e.%s', $attributeItem); 
     } else { 
       $attributeInstance = $this->getAttribute($attributeItem); 

       if ($attributeInstance->getBackend()->isStatic()) { 
         $attrField = 'e.' . $attributeItem; 
       } else { 
         $this->_addAttributeJoin($attributeItem, 'left'); 
         $attrField = $this->_getAttributeFieldName($attributeItem); 
       } 
     } 

     $fullExpression = str_replace('{{attribute}}', $attrField, $fullExpression); 
     $fullExpression = str_replace('{{' . $attributeItem . '}}', $attrField, $fullExpression); 
} 

且行516:

if ($attributeInstance->getBackend()->isStatic()) { 

这看起来是一个“getBackend()”函数的问题。在测试过程中,我看到以下报告错误:

a:5:{i:0;s:34:"Invalid attribute name: school";i:1;s:5727:"#0 /home/opositivo/developositivo/public_html/pinklemon/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(1294): Mage::exception('Mage_Eav', 'Inv??lido nome ...') 

我在magento db内搜索过,但没有找到任何“学校”搜索结果。

有没有人知道这个问题,并可以帮助我?

谢谢。

回答

1

我解决了这个问题。

前516行添加if (!$attrInstance) return true;

你的代码应该是这样的:

foreach ($attribute as $attributeItem) { 
     if (isset($this->_staticFields[$attributeItem])) { 
       $attrField = sprintf('e.%s', $attributeItem); 
     } else { 
       $attributeInstance = $this->getAttribute($attributeItem); 

/** Add this line in code to solve the problem **/ 
      if (!$attrInstance) return true; 


       if ($attributeInstance->getBackend()->isStatic()) { 
         $attrField = 'e.' . $attributeItem; 
       } else { 
         $this->_addAttributeJoin($attributeItem, 'left'); 
         $attrField = $this->_getAttributeFieldName($attributeItem); 
       } 
     } 

     $fullExpression = str_replace('{{attribute}}', $attrField, $fullExpression); 
     $fullExpression = str_replace('{{' . $attributeItem . '}}', $attrField, $fullExpression); 
}