2013-11-04 3 views
1

여기가 내 config.xml입니다. $ blogpost를 표시 할 때 아무 것도 표시되지 않습니다. 모델이 내 데이터베이스의 데이터를 반환하지 않는 이유를 알 수 없습니다.Weblog에서 magento 튜토리얼을 사용하여 load() 함수를 호출하십시오.

치명적인 오류 : 비 객체() 멤버 함수 부하 전화

<global>  
<frontend> 
    <routers> 
     <weblog> 
      <use>standard</use> 
      <args> 
       <module>Magentotutorial_Weblog</module> 
       <frontName>weblog</frontName> 
      </args> 
     </weblog> 
    </routers> 
</frontend> 


<models> 
    <weblog> 
     <class>Magentotutorial_Weblog_Model</class> 
     <resourceModel>weblog_resource</resourceModel> 
    </weblog> 

    <weblog_resource> 
     <class>Magentotutorial_Weblog_Model_Resource</class> 
    </weblog_resource> 
</models> 

컨트롤러

<?php 

class Magentotutorial_Weblog_IndexController extends Mage_Core_Controller_Front_Action { 
    public function testModelAction() { 
     $params = $this->getRequest()->getParams(); 
     $blogpost = Mage::getModel('weblog/blogpost'); 
     echo("Loading the blogpost with an ID of ".$params['id']); 
     $blogpost->load($params['id']); 
     $data = $blogpost->getData(); 
     var_dump($data); 
    } 
} 

블로그 게시물 모델

그것은 이러한 오류 표시
class Magentotutorial_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract 
{ 
    protected function _construct() 
    { 
     $this->_init('weblog/blogpost'); 
    } 
} 
+0

어떤 모델 인스턴스 마법사 ::을 getModel ('웹 로그/블로그 게시물')해야 하는가? 모델 인스턴스 Magentotutorial_Weblog_Model_Blogpost가 있어야합니다. 우리와 함께 공유하십시오 – denSandman

+0

이미 모델을 추가했습니다 –

+0

Ok 내 다음 제안이 모듈을 app/etc/modules에서 활성화 했습니까? 어떻게 든 Magento는 귀하의 모델을 찾을 수 없으며 이는 다른 이유로 인한 것입니다. 그래서 최대한 많은 정보를 제공하십시오 (모든 XML 파일, 모듈에 사용 된 모든 모델) – denSandman

답변

3

앱/코드 코드 아래 교체/지역/Magentotutorial/웹 로그의/etc/config.xml에

<weblog_resource> 
     <class>Magentotutorial_Weblog_Model_Resource</class> 
</weblog_resource> 

<weblog_resource> 
     <class>Magentotutorial_Weblog_Model_Resource</class> 
      <entities> 
       <blogpost> 
        <table>blog_posts</table> 
       </blogpost> 
      </entities> 
    </weblog_resource> 

응용 프로그램/코드/지역/Magentotutorial에서 Blogpost.php를 만들/웹 로그/모델/자원/Blogpost.php 코드 아래에 넣어

는 파일

<?php 
class Magentotutorial_Weblog_Model_Resource_Blogpost extends Mage_Core_Model_Resource_Db_Abstract{ 
    protected function _construct() 
    { 
     $this->_init('weblog/blogpost', 'blogpost_id'); 
    } 
} 
자세한 내용은 코드 실행

..

: - Click here

관련 문제