これが私の config.xml です $blogpost を表示すると、何も表示されません。モデルがデータベースのデータを返さない理由がわかりません。次のエラーが表示されます。
致命的なエラー: オブジェクト以外でのメンバー関数 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');
}
}