You can add a new category attribute with the help of InstallData.php.
Create InstallData.php
File : app/code/PHPCodez/First/Setup/InstallData.php Continue reading Magento 2 Add Category Attribute
You can add a new category attribute with the help of InstallData.php.
Create InstallData.php
File : app/code/PHPCodez/First/Setup/InstallData.php Continue reading Magento 2 Add Category Attribute
To remove customer attribute programatically, create InstallData.php and and define the method intsall() as follows
File : app/code/PHPCodez/First/Setup/InstallData.php Continue reading Magento 2 Remove Customer Attribute Programmatically
To remove product attribute programatically, create InstallData.php and and define the method intsall() as follows
File : app/code/PHPCodez/First/Setup/InstallData.php Continue reading Magento 2 Remove Product Attribute Programmatically
To add product attribute programatically, create InstallData.php and and define the method intsall() as follows
File : app/code/PHPCodez/First/Setup/InstallData.php Continue reading Magento 2 Add Product Attribute Programmatically
The InstallData will be run during the module install and its used to load initial data to DB table.
The module install script will run when you run the following command line
php bin/magento setup:upgrade
File : app/code/PHPCodez/First/Setup/InstallData.php
<?php namespace PHPCodez\First\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $setup->getConnection()->query("INSERT INTO phpcodez_post SET name = 'Post 1'"); $setup->endSetup(); } }
Some time its necessary to create DB tables and add data to tables. Mageto provides some classes using which you can create DB table structure or add data to tables. Following are the important classes
InstallSchema – This class can be used to setup DB structure when modules is instaled for the first time.
InstallData – This class can be used to load the initial data when modules is insttale for the first time. Continue reading SQL Setup Script Magento 2