I created my own module, the table is created in the database and in a phtml I can call:

$res = $model->getExample();

and effectively it function is called.

In Model:

protected function _construct() {
    $this->_init('table_name', 'column_id');
public function getExample(){
    $result = $this->getData();

but 'result' is empty and I know there're data in a database, so... what's the problem?


gettype($this) // is object

$this->load() // Call to a member function load() on a non-object

2 Answers 2


You can use

  • I don't understand, I want to get data from the database inside the Model Jul 6, 2017 at 11:47

To get Data from your model you can call your model directly

//If you want to load from ID


// If You want collection


// If you want from a method defined in your model

// In your model Define a function

public function getMyData(){
    return $this->getCollection(); // Varien Object
    // return return $this->getCollection()->getData(); // Array


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.