I am new to Magento and following tutsplus tutorial. During module development I got this error "Call to a member function sayHello()
on boolean".
Below is my test.php
file in magento(for testing the module):
require_once'app/Mage.php';
Mage::app();
$customer= Mage::getModel("customer/session");
//Mage_catalog_Model_Product
Mage::getModel("catalog/product");
$product = Mage::getModel("demo/product");
$product -> sayHello();
Here is the model file code (Product.php)
class Tutsplus_Demo_Model_Product {
public function sayHello(){
echo "Hi";
}
}
When I removed the $product->sayHello();
to // echo get_class($customer);
it shows the class name. config.xml file is here.
<config>
<global>
<models>
<demo>
<class>Tutsplus_Demo_Model</class>
</demo>
</models>
</global>
</config>
Best Answer
app/etc/modules/Tutsplus_Demo.xml
make sure you define model in
app/code/local/Tutsplus/Demo/etc/config.xml
finally your model
app/code/local/Tutsplus/Demo/Model/Product.php
capitalize the first keyword and extends to
Mage_Core_Model_Abstract
for calling the model