Magento 2 Module
How to add new tables for a custom module in Magento 2
Hide/Show description
Hi Everybody, I am Cuong, Welcome to my Magento 2 Tutorial video series.
#magento2tutorial
Today, I am going to show everybody a best practice, How to add new tables for a custom module in Magento 2.
In the previous video, I showed everyone How to create a new module in Magento 2, I created a new module called PHPCuong_BannerSlider. You can see that practice at the link https://www.youtube.com/watch?v=JwxtiEwEZpk
In this video, I will add two new tables to this module.
1. phpcuong_banners_slider
2. phpcuong_banners_slider_group
You can see the structure of these tables at the link https://ibb.co/d78e28
The table named stores has already existed in the database.
To complete this best practice you need to complete the following high-level steps:
1. Create the file named InstallSchema.php in the path app\code\PHPCuong\Setup
2. Generate the new tables
Run the command line:
- php bin/magento setup:upgrade --keep-generated
If your module has already installed before, you need to delete it in the table named setup_module, then run the command above again
3. Check the results
Go to the database, get a look at the tables named phpcuong_banners_slider, phpcuong_banners_slider_group
It works great!. In the next video, I will show everyone, How to display the banners slider in the Grid in the backend.
Thank you for your watching. If you have any questions about this exercise please feel free to leave a comment below.
Don't forget to like, comment, share and subscribe to my channel for getting the latest videos.
Please do not hesitate to contact me if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.
Get the source codes of this tutorial on the github https://github.com/php-cuong/magento2-banners-slider
-
How to create a new module in Magento 2
How to add new tables for a custom module in Magento 2
How to create a grid using UI component in Magento 2
How to create a form using UI component in Magento 2
How to upload an image using fileUploader in Magento 2
How to validate the data before saving in Magento 2
How to display an image in the admin grid in magento 2
How to use the Inline Edit Component in Magento 2
How to add the JS and CSS files into a custom module in Magento 2
How to add a new Widget into a custom module in Magento 2
How to use plugin in Magento 2
How to use events and observers in magento 2
How to add a new customer attribute in magento 2
How to override a template phtml in Magento 2
How to create the buttons increase and decrease quantity on the product detail page in Magento 2
How to send an email from a custom module in Magento 2
How to create a new shipping method in Magento 2
How to display a static block in a popup in Magento 2
How to add a new checkout step in Magento 2
How to override a knockout HTML template file in Magento 2
How to create a custom console command in Magento 2 - Rebuild URL Rewrite
Increase and decrease quantity in Magento 2 mini cart
How to create a customization cart price rule condition in Magento 2
How to display best seller products on the homepage in Magento 2
How to restrict products by customer group in Magento 2
How to include coupon code in newsletter subscription success email in Magento 2
How to show the registration and login form in a popup in Magento 2
How to remove the decimal from the price in Magento 2
How to use Ajax for the newsletter subscription in Magento 2
How to redirect the customer to a custom page after logging in
How to add the CMS page links to the top menu in Magento 2
How to create lazy loading product images in Magento 2
How to move the Javascript files to the footer in Magento 2
How to remove out of stock items from the shopping cart in Magento 2
How to show review form only for the customer who has purchased the item in Magento 2
How to minify HTML in Magento 2
How to change currency symbol position in Magento 2 (Left to Right)
How to package and publish a magento 2 extension
How to display all products on sale in Magento 2
Magento 2 Admin Security [Send a notification email after logging in successfully]
How to create a custom log file in Magento 2
How to create a custom cron job in Magento 2