Install and Upgrade scripts


Describe the install/upgrade workflow. Where are setup scripts located, and how are they executed? Which types of functionality correspond to each type of setup script?


Magento has introduced a new feature called Declarative Schema since 2.3 which aims to simplify the Magento installation and upgrade processes. So this is out of date on the perspective of preparing for the exam


Install/Upgrade scripts are located in the VendorName/Module/Setup directory.

There are 6 types:

  • Setup/InstallSchema
  • Setup/UpgradeSchema
  • Setup/InstallData
  • Setup/UpgradeData
  • Setup/Recurring
  • Setup/Uninstall

Practice test

You performing a code review on an existing module. You see some interesting files in the Setup/folder.
What files in the Setup/ does Magento understand? (Multiple Choice)
A. Setup/InstallSchema.php
B. Setup/Migrations/…php
C. Setup/Recurring.php
D. Setup/UpgradeSchema.php
E. Setup/InstallDetails.php

Answer A C D

While integrating a merchant’s product information management system with Magento, you create a module
MyCompany_MerchantPim that adds a catalog product EAV attribute pim_entity_id programmatically.
In which type of setup script do you create the EAV attribute?
A. Setup/InstallSchema.php
B. Setup/UpgradeSchema.php
C. Setup/InstallEntity.php
D. Setup/UpgradeData.php

Answer D

UpgradeSchema.php only provides one method: upgrade.
What method do you use to determine what code to execute for what method?
A. Use PHP’s version_compare method to compare the $context->getVersion() with the required version.
B. Use the $setup->compareVersion method.
C. Put the updates into a method named containing the version number that the module is being upgraded to.
D. Check the etc/module.xml XML file for the version number.

Answer A


电子邮件地址不会被公开。 必填项已用*标注