Hi everyone, Namaste, Me Rupak Nepali. In our third video, we describe OpenCart files and folders and told you that next video will be of OpenCart code flow but while making the powerpoint I 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, I 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 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 other which joins with the store and 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 which contains non-language specific data like in above image oc_information, another table is language specific in above image oc_information_description, another table which shows the relationship between store and data in above image oc_information_to_store and last one which shows the relationship between layout and data.

So if I am want to create a custom table which 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);

So, by making database table we completed our fourth video, 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 develop the quality of videos series. You can follow at my twitter account rupaknpl and subscribe our youtube channel onlinegyannepal. Similarly, keep on visiting my personal blog https://webocreation.com where you will find lots of free modules.

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

2 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!

LEAVE A REPLY

Please enter your comment!
Please enter your name here