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.
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:
- Create a model file:
- 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:
Download the full Opencart Database Schema by clicking the PDF below:
How to show relationships and only some databases in PHPmyadmin?
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.