I have the following error occur in my custom module :
Fatal error: Call to a member function setData() on a non-object in /opt/lampp/htdocs/magento/app/code/local/Phparrow/Hello/controllers/IndexController.php
My code is as follows -
config.xml
<global>
<blocks>
<hello>
<class>Phparrow_Hello_Block</class>
</hello>
</blocks>
<helpers>
<hello>
<class>Phparrow_Hello_Helper</class>
</hello>
</helpers>
<models>
<hello>
<class>Phparrow_Hello_Model</class>
<resourceModel>hello_mysql4</resourceModel>
</hello>
<hello_mysql4>
<class>Phparrow_Hello_Model_Mysql4</class>
<entities>
<hello>
<table>hello</table>
</hello>
</entities>
</hello_mysql4>
</models>
<resources>
<hello_setup>
<setup>
<module>Phparrow_Hello</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</hello_setup>
<hello_write>
<connection>
<use>core_write</use>
</connection>
</hello_write>
<hello_read>
<connection>
<use>core_read</use>
</connection>
</hello_read>
</resources>
</global>
magento\app\code\local\Phparrow\Hello\Model\Hello.php
<?php
class Phparrow_Hello_Model_Hello extends Mage_Core_Model_Abstract
{
public function _construct(){
print 'test';
$this->_init('hello/hello');
print 'test1';
}
}
magento\app\code\local\Phparrow\Hello\Model\mysql4\Hello.php
<?php
class Phparrow_Hello_Model_Mysql4_Hello extends Mage_Core_Model_Mysql4_Abstract
public function _construct()
{
$this->_init('hello/hello', 'hello_id');
}
}
magento\app\code\local\Phparrow\Hello\Model\mysql4\Hello\Collection.php
<?php
class Phparrow_Hello_Model_Mysql4_Hello_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct(){
$this->_init('hello/hello');
}
}
magento\app\code\local\Phparrow\Hello\controllers\IndexController.php
class Phparrow_Hello_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$model1= Mage::getModel('hello/hello');
echo get_class($model1);
$model1->setData('name'->'Harsh','contact'->'8445895621');
$model1->save();
}
}
I have a hello table have that has three fields:
hello_id, name, contact
Why would this not work in Linux when it successfully executes in Windows?