How to create the CRUD operations with Admin Grid in Magento 2?
I want to :
- First of create frontend input form.
- frontend input form data get in admin grid.
- In admin grid Create delete options.
- In admin Grid Create edit (UPDATE) options.
How to achieve this. Please give the best way and the solution.
1 Answer 1
Create the CRUD operations with Admin Grid in Magento 2
Step-1 : Choose your Module Name like VendoreName and ModuleName
Step-2 : Create a folder like this /app/code/VendoreName/ModuleName
Step-3 : First create registration.php at app/code/VendoreName/ModuleName
Step-4 : Create module.xml at app/code/VendoreName/ModuleName/etc
Step-5 : Choose admin route name and create in routes.xml at app/code/VendoreName/ModuleName/etc/adminhtml
Step-6 : Create on table structure add into InstallSchema.php at app/code/VendoreName/ModuleName/Setup
Step-7 : Create Model files for access your table for DML operation.
Step-8 : Choose admin Conroller name(Index) and create folder like this app/code/VendoreName/ModuleName/Controller/Adminhtml/Index
Step-9 : Create your admin Action file for create admin pages At app/code/VendoreName/ModuleName/Controller/Adminhtml/Index for show grid and manupulate data in admingrid.(Index.php,Add.php,Delete.php,Edit.php,MassDelete.php,MassStatus.php,Save.php)
Step-10: But right now our module is not show. Now Create one menu and add this menu into magento menu list. craete menu.xml at app/code/VendoreName/ModuleName/etc/adminhtml (Menu action must assige carefull like AdminRouteName/AdminControllerName/AtcionFileName)
Step-11: Now we have to create layout at app/code/VendoreName/ModuleName/view/adminhtml/layout (file name must be like this adminroutname_admincontollername_actionfilename.xml all latters are small case and same as you define in file.)
Step-12: You can create grid using Block and Ui-component follow this click here
Step-13: Now admin part is over So create frontend route name routes.xml at app/code/VendoreName/ModuleName/etc/frontend
Step-14: Create Frontend Contoller Name Folder like (Index) like app/code/VendoreName/ModuleName/Controller/Index
Step-15: create action in it as you required. (Index.php,Add.php,Delete.php,Edit.php,MassDelete.php,MassStatus.php,Save.php)
Step-16: create layout for it. layout name must be like this frontendroutename_frontendcontrollername_frontendactionfilename.xml
Step-17: in layout file you call Block and phtml files for show content. click here for more
Step-18: Now your module is ready to use
Please check this all files are created and running well click here to show
Note: you can also use some step before and after as you comfort. but some step are required like route create, layout create etc
I Hope This Helps You
-
Thanks but i want to without module creator. And you explains step create. You only share me steps. ThanksMohit Patel– Mohit Patel2020年07月15日 13:50:28 +00:00Commented Jul 15, 2020 at 13:50
-
Yes without any module creatorMohit Patel– Mohit Patel2020年07月16日 09:45:40 +00:00Commented Jul 16, 2020 at 9:45
-
Thank you . your module All steps is best and i make +1 upvote but your provided module doesn't work.Mohit Patel– Mohit Patel2020年07月16日 15:59:54 +00:00Commented Jul 16, 2020 at 15:59
-
Sorry, i have find Your module is working perfect. My magento 2 problem.Thanks @Msquare.Mohit Patel– Mohit Patel2020年07月17日 04:55:07 +00:00Commented Jul 17, 2020 at 4:55
-
and other Please one request check this link and provide debug step . magento.stackexchange.com/q/317559/85907Mohit Patel– Mohit Patel2020年07月17日 04:56:24 +00:00Commented Jul 17, 2020 at 4:56