10
Create A Module With Custom Database Table In Magento 2 Provided By Mageworld A Leading Magento Provider

Create A Module With Custom Database Table In Magento 2

Embed Size (px)

Citation preview

Page 1: Create A Module With Custom Database Table In Magento 2

Create A Module With Custom Database Table In Magento 2

Provided By Mageworld A Leading Magento Provider

Page 2: Create A Module With Custom Database Table In Magento 2

OUTLINE

Step 1

• Create a new module (Tutorial_SimpleNews)

Step 2

• Create configuration file.

Step 3

• Create the installation file.

Step 4

• Activate the module.

Page 3: Create A Module With Custom Database Table In Magento 2

Create a new table in the database of Magento 2 with the structure as follows:

Table name: tutorial_simplenews

Page 4: Create A Module With Custom Database Table In Magento 2

Step 1: Create a new module (Tutorial_SimpleNews)

Page 5: Create A Module With Custom Database Table In Magento 2

Step 2: Create configuration file.

Create file: app/code/Tutorial/SimpleNews/etc/module.xml

Purpose: declare the module

Page 6: Create A Module With Custom Database Table In Magento 2

Step 3: Create the installation file.

Create file: app/code/Tutorial/SimpleNews/Setup/InstallSchema.php

Purpose:  declare and create the custom table

=> Go to our blog tutorial for full source code

Page 7: Create A Module With Custom Database Table In Magento 2

Step 4: Activate the module.

Active this module by opening:

 app/etc/config.php file Add this line into it

Step 4.1:

Page 8: Create A Module With Custom Database Table In Magento 2

Step 4: Activate the module.

Open the Command in

Windows

Go to Magento root

folder

Run this command line

to install module

Module: bin\magento setup:upgrade

Step 4.2:

Page 9: Create A Module With Custom Database Table In Magento 2

Step 4: Activate the module. Step 4.3: Check database: the tutorial_simplenews table

is created successfully