Magento 2. Databases and modules.

Programmatically adding product attributes

(We need the module that we created in the previous recipes)

STEP I – Create an upgrade script:

Create the file:


STEP II – Raise the module version:

Change the file:



Raise the module version to 2.0.2.

<module name=”Magedd_Education” setup_version=”2.0.2“/>

STEP III – Upgrade setup by CLI

/var/www/local/{your-project-name.dev} > php bin/magento setup:upgrade

Log in to the backend and look for a product. You will see that the attribute is added to the Magedd tab