2012-03-01 73 views
1

我是magento的新手。我正在嘗試編寫模塊來報告有關網站的濫用情況。我在下面的頁面上填寫了表單。如何修復magento中的getIdFieldName致命錯誤?

http://localhost/magento/vendorinfo/page/report/ 

模塊名稱是vendorinfo,控制器是頁面,動作是報告。下面是我ReportAction這是從我Venderinfo模塊

public function reportsubmitAction() { 
     $data = $this->getRequest()->getParams(); 
try { 

      $insert_data = array(); 
      $insert_data['reporter_name'] = $data['name']; 
      $insert_data['reporter_email'] = $data['email']; 
      $insert_data['report_category'] = $data['category_type']; 
      $insert_data['reporter_comment'] = $data['report_comments']; 


      $model = Mage::getModel('vendorinfo/report'); 
      $model->setData($insert_data)->setId(null); // i have got the error on this line 
      $model->setCreatedTime(now())->setUpdateTime(now()); 
      $model->save(); 

      Mage::getSingleton('frontend/session')->addSuccess(Mage::helper('articles')->__('Report was successfully submitted')); 
      Mage::getSingleton('frontend/session')->setFormData(false); 
     } catch (Exception $e) { 
      Mage::getSingleton('frontend/session')->addError($e->getMessage()); 
      Mage::getSingleton('frontend/session')->setFormData($data); 
      $this->_redirect('vendorinfo/page/report', array()); 
      return; 
     } 

    } 

採取當我提交我打電話上述行動,我的數據存儲到數據庫的形式。但我已經有了下面這樣的錯誤,

Fatal error: Call to a member function getIdFieldName() on a non-object in C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Abstract.php on line 151

而且我有以下文件夾結構下創建2個模型文件,

1 Venderinfo /型號/ Report.php

class Comp_Vendorinfo_Model_Report extends Mage_Core_Model_Abstract 
{ 
    public function _construct() 
    { 
     parent::_construct(); 
     $this->_init('vendorinfo/report_abuse'); 

    } 
} 

2.Venderinfo /型號/ Mysql4 /報告/ Collection.php

class Comp_Vendorinfo_Model_Mysql4_Report_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract 
    { 
     public function _construct() 
     { 
      parent::_construct(); 
      $this->_init('vendorinfo/report_abuse'); 
     } 
    } 

我在這做錯了什麼?

請在此建議。

+2

如果您的magento版本> = 1.6,最好使用Resource not Mysql4。 – 2012-03-01 09:05:56

回答

0

請去Magento的根文件 - >應用程序/等 ,檢查local.xml文件, 這是不是可以在這裏請複製local.xml中另一個Magento的目錄,在這裏編輯&副本。

問題得到解決

相關問題