Skip to main content
added 882 characters in body
Source Link
Sander Mangel
  • 37.5k
  • 5
  • 80
  • 148

It initiates the resource model this model uses to commit data to the database.

So in this case that would be the file app/code/[local|community]/Magentotutorials/Weblog/Model/Resource/Blogpost.php

[EDIT] to answer @easymoden00b question, the _init method can be found in Mage_Core_Model_Abstract which directly calls _setResourceModel in the same class

/**
 * Set resource names
 *
 * If collection name is ommited, resource name will be used with _collection appended
 *
 * @param string $resourceName
 * @param string|null $resourceCollectionName
 */
protected function _setResourceModel($resourceName, $resourceCollectionName=null)
{
    $this->_resourceName = $resourceName;
    if (is_null($resourceCollectionName)) {
        $resourceCollectionName = $resourceName.'_collection';
    }
    $this->_resourceCollectionName = $resourceCollectionName;
}

This stores the Resource item and collection class names for further use when retrieving and writting to and from the database

It initiates the resource model this model uses to commit data to the database.

So in this case that would be the file app/code/[local|community]/Magentotutorials/Weblog/Model/Resource/Blogpost.php

It initiates the resource model this model uses to commit data to the database.

So in this case that would be the file app/code/[local|community]/Magentotutorials/Weblog/Model/Resource/Blogpost.php

[EDIT] to answer @easymoden00b question, the _init method can be found in Mage_Core_Model_Abstract which directly calls _setResourceModel in the same class

/**
 * Set resource names
 *
 * If collection name is ommited, resource name will be used with _collection appended
 *
 * @param string $resourceName
 * @param string|null $resourceCollectionName
 */
protected function _setResourceModel($resourceName, $resourceCollectionName=null)
{
    $this->_resourceName = $resourceName;
    if (is_null($resourceCollectionName)) {
        $resourceCollectionName = $resourceName.'_collection';
    }
    $this->_resourceCollectionName = $resourceCollectionName;
}

This stores the Resource item and collection class names for further use when retrieving and writting to and from the database

Source Link
Sander Mangel
  • 37.5k
  • 5
  • 80
  • 148

It initiates the resource model this model uses to commit data to the database.

So in this case that would be the file app/code/[local|community]/Magentotutorials/Weblog/Model/Resource/Blogpost.php