Things to consider while creating database Model Data OpenCart Guide

Hi everyone, Namaste, Me Rupak Nepali. In our third video, we describe OpenCart files and folders and told you that the next video will be of OpenCart code flow but while making the PowerPoint we feel like first, we need to know about the database and global methods of OpenCart then it will be easier to understand the OpenCart code flow. So, in this video, we will go through the OpenCart database.

Things to consider while creating database OpenCart Guide

  • OpenCart supports multistore
  • It supports multi-language
  • Multiple Layouts
  • oc_ is a database prefix
  • If you are creating the table then better to make 4 tables, one which will contain language-specific contents here oc_information_description, another is non-language specific oc_information and another which joins with the store, and the last one which joins to the layout.
database schema creation OpenCart

Create custom table schema in OpenCart:

If you are going to create a custom table in OpenCart then you have to think of four tables. One table contains non-language-specific data like in the above image oc_information, another table is language-specific in the above image oc_information_description, another table shows the relationship between store and data in the above image oc_information_to_store and the last one which shows the relationship between layout and data.

So if I want to create a custom table that contains testimonials then my table schema will be like in the image:

custom table schema for Testimonial

Code example:

  • Create a model file:
    admin>>model>>catalog>>information.php
  • Create a class as per the folder and file structure:
    class ModelCatalogInformation extends Model
  • Create a Method inside the class:public function addInformation($data)
  • In Controller, first, load the model then call the method:
    $this->load->model(‘catalog/information’);
    $this->model_catalog_information->addInformation($this->request->post);

Download the full Opencart Database Schema by clicking the PDF below:

How to show relationships and only some databases in PHPmyadmin?

PHPmyadmin Tables relationship

So, by making the database table we completed our fourth video, we hope you liked it. As always please don’t forget to post your questions or comments so that I can add extra topics or things that I need to develop which will help to create the quality of the video series. You can follow me at my Twitter account @rupaknpl and subscribe to our youtube channel Opencart Tutorials. Similarly, keep on visiting my personal blog https://webocreation.com where you will find lots of free modules.

The next video will see “OpenCart Library Global Objects’ Methods“. So, see you in the following video, and happy learning, and thanks for watching the videos.

Previous articleDescribing files and folder of OpenCart Framework
Next articleExploring the code of default Featured Module

4 COMMENTS

  1. Hello, I would like to create an empty OpenCart database schema on a local SQL Server. Please can someone tell me where I can find SQL to create all the tables?

    Thanks!

  2. Hello sir,

    I hope you be doing great,
    I have had one issue trying a lot for some time to apply a server-side data table in one of my opencart project but I get field, anyhow I managed to do it but just one table data is possible to show I can not use join queries to fetch data from max tables which is more important for me I have been following from long and learned a lot from your website and videos,
    if possible to help me or guide me through this will be more than happy,
    how to implement a serverside data table in an Opencart?
    hope you receive my email and help me through this issue,
    best regards,

LEAVE A REPLY

Please enter your comment!
Please enter your name here