MVC pattern in Opencart Implementation

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.

ex.             $this->load->model(‘affiliate/activity’);

Inside view folder you will be able to see all javascript files, images,stylesheets etc.. which are used to generate front end of application.

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.


Looking for quality OpenCart Web Hosting? Look no further than Arvixe Web Hosting.

Tags: , , | Posted under OpenCart | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *