Opencart is created based on PHP language and it follows MVC pattern. So whole application is divided into three tiers Model, View and Controller. This is very popular pattern and most probably you might be well aware about this. Still for those who are not aware about this first brief introduction of MVC.
As per the definition of MVC from wikipedia:
Model–view–controller (MVC) is a software architectural pattern mostly (but not exclusively) for implementing user interfaces on computers. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.
Main three components are Model, View and Controller
Model: It contains business logic, rules and all internal implementation. For instance if you have database oriented application then logic of fetching related data from database and making it suitable for view is part of model.
View: It contains all user facing components like HTML, It relies on Model to get appropriate data for display.
Controller: It is kind of mediator between Model and view whenever view is updated Controller pass command to appropriate model to do changes in back end and also invoke appropriate view when model is updated.
Advantage of dividing application in these three layer is to decoupled application in three layers so that if any one of layer has major changes there will be minimal impact on other layers.
Now Opencart also follow same MVC pattern and if you go inside it’s installation directory you will be able see how they have cleanly separated all three layers.
Inside model related folder and open up any one of the file you will be able to see things like logic for fetching data from database, then manipulating that data based on business logic and they generated output for view.
Inside controller folder if you open any of the file you will be able to see logic for loading appropriate model and bit of logic related to polishing of data before passing it to view.
We will be going through complete flow of any one of the functionality in upcoming posts to give you clear picture of how flow goes in opencart application. Till then feel free to post your comments to discuss your views or queries on related topic.