cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Magento 2.2 module installation precedence?

How to change Magento 2.2 module installation precedence?

I inherited a Magento 2.2 project and I'm following the next steps to installing it at my local environment:

 

1. Run command

bin/magento setup:di:compile

2. Run command to install magento

bin/magento setup:install \
  --base-url=http://localhost:8080 \
  --db-host=db --db-name=magento --db-user=root --db-password=secret \
  --admin-user=admin --admin-password=admin123 --language=es_MX \
  --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
  --currency=MXN --timezone=America/Mexico_City --use-rewrites=1

 

Installation process starts installing core Magento modules but fails when trying to install a custom module stored in app/code/CustomModule. It looks like the module code is trying to access Magento configuration to store some settings related to the custom module with the following error:

[Zend_Db_Statement_Exception] 
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.customer_address_entity' doesn't exist, query was: DESCRIBE `customer_address_entity`

 

This makes me think that the module relies on some core Magento modules or setup. This is why I want to change the installation order of modules. Is this possible and how it can be done?

 

Thank you!

4 REPLIES 4

Re: How to change Magento 2.2 module installation precedence?

Hello @uziel_bueno 

 

You can disable all custom modules before Magento installations. Try to disable in app/etc/config.php

delete modules entry from setup_module also for these specific modules.

once Magento install you can again enable these modules and run below commands:

 

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setip:static-content:deploy
php bin/magento cache:flush
Manish Mittal
https://www.manishmittal.com/

Re: How to change Magento 2.2 module installation precedence?

@Manish Mittal Thanks for replying!

I tried what you suggest but it has no effect due to the config.php file is regenerated once I run the setup:install command enabling the modules I previously disabled with a 0 value.

This is a little annoying, maybe I'm missing something else?

Thank you!

Re: How to change Magento 2.2 module installation precedence?

Hello @uziel_bueno 

 

Add sequence in module.xml of that module to exexute.

<sequence>
<module name="Magento_Customer"/>

 

It will work.

Manish Mittal
https://www.manishmittal.com/

Re: How to change Magento 2.2 module installation precedence?

You can define your module loading sequence using <sequence> node in your custom module's module.xml file. You can find more details on below URL


https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/module-load-order.html

If your module deals with customer or address data try adding Magento's default customer module inside sequence node. So when Magento will install your module it will first check the sequence[which means your module is dependent of customer module] and then will install Magento_Customer module first and after that will install your module. You can add multiple sequence nodes if needed.

Sample Code

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="YourNameSpace_YourModule" setup_version="0.0.1">
        <sequence>
	    <module name="Magento_Customer" />
        </sequence>
    </module>
</config>