How to Create Admin Grid,edit/add in Magento 2

How to Create Admin Grid,edit/add in Magento 2

I’m sharing with you this post ,which guide you how to create admin grid,edit/add in Magento 2.I’m going to use Magento 2 Community Edition (CE) for this purpose.
If you are familiar with Magento 1 grid then it easy to understand Magento 2 Grid, which is table row listing patterns of your database table. Magento Grid provide you all kind of operations like: sort, filter, delete, update item, etc.
You can create below directory structure before start.We will need all those directory structure for create admin grid edit/add grid row and installer.

app/code/Ak/GridExample
app/code/Ak/GridExample/etc
app/code/Ak/GridExample/etc/Adminhtml
app/code/Ak/GridExample/Block/Adminhtml
app/code/Ak/GridExample/Block/Adminhtml/Grid
app/code/Ak/GridExample/Block/Adminhtml/Grid/Edit
app/code/Ak/GridExample/Model
app/code/Ak/GridExample/Model/ResourceModel
app/code/Ak/GridExample/Model/ResourceModel/Grid
app/code/Ak/GridExample/Setup
app/code/Ak/GridExample/Controllers/Adminhtml
app/code/Ak/GridExample/view/adminhtml/layout

 

Steps to Create Admin Grid

Step 1: Create Module Configuration File
Step 2: Create Module Registration File
Step 3: Create Composer File for Auto Install
Step 4: Create Menu Configuration File
Step 5: Create Database schema
Step 6: Create Model File
Step 7: Create Model Interface File
Step 9: Create Resource Model File
Step 10: Create Resource Collection File
Step 11: Create Admin Grid using Ui Component
Step 12: Create Map Data File & UI Action
Step 13: Create “Create”,Save,MassDelete etc. Action Files (Controller Files)
Step 14: Create Option status file
Step 15: Create Route File
Step 16: Create Grid Display Layout File
Step 17: Create Block File for Save/Edit Data process file
Step 18: Create Layout File for Render the Form

Step 1:  Create Module Configuration File

Create The Module Configuration File Named Module.Xml on below path.
Path: app/code/Ak/GridExample/etc

 

 

Step 2:  Create Module Registration File

Create The Module Registration File Named Registration.php on below path.
Path: app/code/Ak/GridExample/

 

 

Step 3:  Create Composer File for Auto Install

Create The Module Composer File Named composer.json on below path.
Path: app/code/Ak/GridExample/

 

 

Step 4:  Create Menu Configuration File 

Create The admin menu configuration file named Menu.Xml on below path.
Path: app/code/Ak/GridExample/etc/Adminhtml

 

Step 5:  Create Database schema 

Create The Installer file named InstallSchema.php on below path.
Path: app/code/Ak/GridExample/Setup

 

 

Step 6:  Create Model File

Create The Model file named GridExample.php on below path.
Path: app/code/Ak/GridExample/Model

 

 

Step 7:  Create Model Interface File

Create The Interface file named GridExampleInterface.php on below path.
Path: app/code/Ak/GridExample/Api/Data

 

 

Step 9:  Create Resource Model File 

Create The Resource Model file named GridExample.php on below path.
Path: app/code/Ak/GridExample/Model/ResourceModel

 

 

Step 10: Create Resource Collection File

Create The Collection file named Collection.php on below path.
Path: app/code/Ak/GridExample/Model/ResourceMode/GridExample

 

 

Step 11: Create Admin Grid using Ui Component

Create Ui Component For Grid Row List, file named gridexample_record_grid_list.xml on below path.
Path: app/code/Ak/GridExample/View/Adminhtml/Ui_component

 

 

Step 12: Create Map Data File

Create Map Data file named di.Xml on below path.
Path: app/code/Ak/GridExample/etc

 

 

UI Action :

 

For Action Create Action Class Action.Php In App/Code/Ak/GridExample/Ui/Component/Listing/GridExample/Column

 

 

 

 

Step 13: Create “Create”,Save,MassDelete etc. Action Files

We need to create specific controller file for each  like  MassDelete.php for Mass Delete action etc.

Create list row controller file on below path with AddRow.php,
Path : app/code/Ak/GridExample/Controllers/Adminhtml/GridExample

 

Create Save  row controller file with Save.php,

 

Create a INDEX.php file on same path  by which we can prepare and/or invoke  UI Component And Data Provider.

 

 

Create a file by which we can delete multiple rows . File name as MassDelete.php.

 

 

 

Step 14: Create Option status file

Create Status.Php on below path for status option
Path : App/Code/Ak/GridExample/Model

 

Step 15: Create Route File Routes.Xml on below path.
Path : App/Code/Ak/GridExample/etc/Adminhtml

 

Step 16: Create Grid Display Layout File gridexampl_gridexampl_index.xml on below path.
Path : App/Code/Ak/GridExample/View/Adminhtml/Layout

 

Step 17: Create Block File for Save/Edit Data process file

Note : Make sure all controller file should available before the block.

a)

Create Block File Of Form AddRow.Php on below path.
Path: App/Code/Ak/GridExample/Block/Adminhtml/GridExample/

 

 

 

b)
Create Block File Of Form With Field Form.Php on below path.
Path : App/Code/Ak/GridExample/Block/Adminhtml/GridExample/Edit

Step 18: Create Layout File for Render the Form

Create Layout File for addrow form gridexampl_gridexampl_addrow.Xml on below path. Path: App/Code/Ak/GridExample/View/Adminhtml/Layout

 

……………………………………………….

How to Install Magento 2 on Ubuntu (16-04 or 16-10)

I’m sharing with you this post ,which guide you how to install Magento on Ubuntu 16.x.
Magento 2 of Community Edition (CE) is a free, open-source e-commerce platform.

Before You Start:

#Install and configure LAMP

#Install and configure Composer

#Validate current configuration as per magento System Requirements

My dev machine Configuration are :

Linux Ubuntu 16.10.x

Php 7.0.x

Mysql 5.0.12.x

Composer 1.4.x

 

Install via GitHub

First we must clone Magento repo from here: https://github.com/magento/magento2 or you can download releases on https://github.com/magento/magento2/releases

Create empty directory and run:

After deploying has been finished, run:

 

Update Write permission: 

Below directory should be writable,

generated, var, pub

 

Install Magento 2 : My setup configuration was looks like this:

Change your base-url, db-name, db-password, admin-email, admin-password to match your local setup.

Update VirtualHost Configuration : 

Open the apache2.conf file and AllowOverride all for Directory permission.

 

Enable Debug and error :

Open index.php and add below code on top :

 

REINDEX DATA: 

 

More About Re-index Data : Click here 

 

Final View: 

magento2-home

 

 

magento2-admin-home