I'm working on Alan Storm's Weblog tutorial. I can retrieve a single record from the model (Model->load(id)) but the call to Model->getCollection() is returning false.
Here is the global section from my config.xml:
<global>
<models>
<weblog>
<class>Magentotutorial_Weblog_Model</class>
<resourceModel>weblog_resource</resourceModel>
</weblog>
<weblog_resource>
<class>Magentotutorial_Weblog_Model_Resource</class>
<entities>
<blogpost>
<table>blog_posts</table>
</blogpost>
</entities>
</weblog_resource>
</models>
</global>
My Model in app/code/local/Magentotutorial/Weblog/Model/Blogpost.php:
<?php
class Magentotutorial_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('weblog/blogpost');
}
}
My resource model in app/code/local/Magentotutorial/Weblog/Model/Resource/Blogpost.php - This works, I can call Model->load(id) successfully:
<?php
class Magentotutorial_Weblog_Model_Resource_Blogpost extends Mage_Core_Model_Resource_Db_Abstract {
protected function _construct()
{
$this->_init('weblog/blogpost', 'blogpost_id');
}
}
My Collection class in app/code/local/Magentotutorial/Weblog/Model/Resource/Blogpost/Collection.php:
<?php
class Magentotutorial_Weblog_Model_Resource_Blogpost_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
protected function _construct()
{
$this->_init('weblog/blogpost');
}
}
The method in the controller that tries to get the collection. The var_dump call prints "bool(false)":
public function showAllBlogPostsAction() {
$posts = Mage::getModel('weblog/blogpost')->getCollection();
var_dump($posts);
foreach($posts as $blogpost){
echo '<h3>'.$blogpost->getTitle().'';
echo nl2br($blogpost->getPost());
}
}
Here is my source tree for the module:
Update: I determined that the Collection.php file was not being included. If I include that file manually (from indexController.php) it works. Now I'm trying to figure out why the file isn't getting included.
Thanks very much for any help!