AD0-E716 · Question #32
An Adobe Commerce developer has created a module that adds a product attribute to all product types via a Data Patch-According to best practices, how would the developer ensure this product…
The correct answer is C. Make the Data Patch implement \Magento\Framework\setup\Patch\PatchRevertabieinterface. According to the Develop data and schema patches guide for Magento 2 developers, data patches revert() method contains the instructions to undo the data modifications made by the patch. To ensure that the product attribute is removed when the module is uninstalled, the…
Question
An Adobe Commerce developer has created a module that adds a product attribute to all product types via a Data Patch-According to best practices, how would the developer ensure this product attribute is removed in the event that the module is uninstalled at a later date?
Options
- AAdd an Uninstall.php file extending \l1agento\Framework\Setup\UninstallInterface tO the
- BAdd instructions to the module's README.md file instructing merchants and developers that they
- CMake the Data Patch implement \Magento\Framework\setup\Patch\PatchRevertabieinterface
How the community answered
(44 responses)- A7% (3)
- B11% (5)
- C82% (36)
Explanation
According to the Develop data and schema patches guide for Magento 2 developers, data patches revert() method contains the instructions to undo the data modifications made by the patch. To ensure that the product attribute is removed when the module is uninstalled, the developer should make the data patch implement PatchRevertabieinterface and implement the revert method to remove the product attribute using EavSetupFactory or AttributeRepositoryInterface. Verified schema/data-patches.html
Topics
Community Discussion
No community discussion yet for this question.