If I have simple module, is there any reason why I should ever use Model and not just write everything in controller? Are there any limitations to this?

  • Model is used if you want to interact with database. Otherwise you can use controller. – Neha Raval Apr 29 '17 at 4:20

Models are generally used for the deal with data and logic implementation.

Main advantages of model classes are that they are reusable. You can use anywhere and anytime in your application.

To avoid writing all logic in controller and using the model because we can use that logic in anywhere in app without modification.

If you write all logic in controller you can only use that within you action or controller class.

| improve this answer | |
  • Thank you! Is it possible to call a Model from another extension to my module? – Jurģis Toms Liepiņš Apr 29 '17 at 6:41
  • 2
    Yes it can be called. All you need is to pass module handle and then relative path of your model file. Mage::getModel('module_handle/myModel'); will call the MyModel.php under Model folder of your module whose handle is module_handle. – magento noob Apr 29 '17 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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