Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento Models and ORM Basics Question . 
 
arist1213
Jr. Member
 
Total Posts:  1
Joined:  2012-11-04
 

Hi, everyone. Absolutely, I am newer for magento ce . I followed this great tutorial http://alanstorm.com/magento_models_orm . But I got stuck by now.

I am using magento 1.7.0.2 and below is my copy code.

My question is : How to get data from the model based on the config.xml which in the attachment ?

My module’s model directory is:

app/local/Alanstormdotcom/Weblog/Model/Blogpost.php

<?php
class Alanstormdotcom_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract 
{
    
protected function _construct()
    
{
        $this
->_init('weblog/blogpost');
    
}   
}

app/local/Alanstormdotcom/Weblog/Model/Mysql4/Blogpost.php

<?php
class Alanstormdotcom_Weblog_Model_Mysql4_Blogpost extends Mage_Core_Model_Mysql4_Abstract{
    
protected function _construct()
    
{
        $this
->_init('weblog/blogpost''blogpost_id');
    
}
}

and my controllers is:

app/local/Alanstormdotcom/Weblog/controllers/IndexController.php

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

last the error msg is :

Loading the blogpost with an ID of 1
Warning: include(D:\is\xampp\htdocs\magento\includes\src\Alanstormdotcom_Weblog_Model_Blogpost.php): failed to open stream: No such file or directory in D:\is\xampp\htdocs\magento\includes\src\Varien_Autoload.php on line 93

I hope someone can help me with this question. I got head scratch by this.

Image Attachments
weblog_config.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

I think is because you have the compilation turned on.
Disable it from system->tools->compilation.

You can enable it again after you see it works.

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top