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 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 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.
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 the 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:
- 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:
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 develop the quality of the videos 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.
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 the videos.