-1

I created one module in magento Local->Vehicle->Bike

In controller i write code for model:

$model_obj = Mage::getModel('bike/honda'); $model_obj->setName( $name );

It gives error like

Fatal error: Call to a member function setName() on a non-object in /opt/lampp/htdocs/magento/app/code/local/Vehicle/Bike/controllers/IndexController.php on line 40

Yogesh Karodiya
  • 225
  • 5
  • 15

2 Answers2

0

Your call

Mage::getModel('bike/honda')

returns null. That's why $model_obj is a non-object and you get that error.

ciruvan
  • 5,143
  • 1
  • 26
  • 32
0

There is no function named setName() in the model bike/honda or try to use $this->model_obj->setName( $name );

Saranya Sadhasivam
  • 1,296
  • 6
  • 9
  • 1
    This is an incorrect guess. This error is indicating that `$model_obj` is not an object. If there were no method `setName()`, the error would be: `Fatal error: Call to undefined method`. – nickb Jul 30 '13 at 13:16