0

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?

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

1 Answer 1

1

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.

2
  • Thank you! Is it possible to call a Model from another extension to my module? Commented Apr 29, 2017 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. Commented Apr 29, 2017 at 6:48

Your Answer

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

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