How to get Dependent(Sequence) module list of a specific module programmatically in Magento 2?

You can get the list of dependent module and schema version for a specific module using programmatically by Magento\Framework\Module\ModuleList class.

You can manually check the list of the dependent module for a module using an etc/module.xml file.

Let’s we Check the dependency list for a Catalog Module. you can check the module.xml file for catalog module is,

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magento_Catalog" >
        <sequence>
            <module name="Magento_Eav"/>
            <module name="Magento_Cms"/>
            <module name="Magento_Indexer"/>
            <module name="Magento_Customer"/>
        </sequence>
    </module>
</config>

you can check above XML, There are four modules on which catalog is dependent.  Continue reading “How to get Dependent(Sequence) module list of a specific module programmatically in Magento 2?”

Magento 2 Get all the Enable (Active) module list programmatically.

You can get the list of all Enable module in Magento 2.  You can manually check your all the enable module list from app/etc/config.php file module name with status set to 1.

‘Magento_Store’ => 1 Store Module is Enable.

‘MSP_ReCaptcha’ => 0 Recaptcha Module is disable. Continue reading “Magento 2 Get all the Enable (Active) module list programmatically.”

How to add CMS Static Block Programmatically using Setup Patchdata in Magento 2?

From Magento 2.3, Core modules use the declarative schema approach rather than setup upgrade scripts. This is the new recommended approach for Magento versions 2.3 and upper version.

All the InstallData and UpgrageData will be replaced by Data Patch Versioning.

Now you have to create Setup/Patch/Data folder and create the class file for create/update attribute or add sample data in Magento. Continue reading “How to add CMS Static Block Programmatically using Setup Patchdata in Magento 2?”