QuestionQ11

Working with Databases and EAV

An Adobe Commerce developer has built a module that adds a product attribute to every product type through a Data Patch.

According to best practices, how should the developer ensure that this product attribute is removed if the module is later uninstalled?

  • A Add an Uninstall.php file extending \Magento\Framework\Setup\UninstallInterface to the module's setup directory and implement the uninstall method.
  • B Add instructions to the module's README.md file instructing merchants and developers that they must manually remove this attribute if they want to uninstall the module.
  • C Make the Data Patch implement \Magento\Framework\Setup\Patch\PatchRevertableInterface and implement the revert method to remove the product attribute.
Explanation

A data patch that implements \Magento\Framework\Setup\Patch\PatchRevertableInterface can define revert() to undo the changes made by apply(). Adobe Commerce runs revertible data patches during module:uninstall, so revert() should remove the product attribute.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!