简体   繁体   中英

magento disable modules script

I am doing some testing on a new feature, however, there is a conflict with a module that we have running. I have to disable the module in the xml file of the etc folder(set active to false) to do testing, but turn it on again to check whether compatibility is fixed. This is quite a nuisance and I was wondering if there is a script that can turn it off and on when I run it.

This is not the first time i have run into the issue.

I am somewhat new to magento so I just want to make sure I am doing things correctly. Here is what I threw together so far, but it probably needs corrections, and I'm not sure what to put in some spots. This is to get the module disabled.

<?php
$dom=new DOMDocument();
$dom->load("myExt.xml");

$root=$dom->documentElement; 

$modules=$root->getElementsByTagName('module');


foreach ($modules as $module) {
    $active=$module->getElementsByTagName('active')//Not sure how to end this line
    $active='false'; //This is probably incorrect

}
$dom->save('myExt.xml');
?>

Thanks in advance!

Consider just using xmllint, which can do simple xml edits more trivially than writing a php program to do it:

{
    echo 'cd //active'
    echo 'set false'
    echo 'save'
} | xmllint --shell app/etc/modules/YourModule.xml

You could even make this into a simple shell function:

##
# Toggle Magento module active or inactive
magetogmod() {
    {
        echo 'cd //active'
        echo "set $1" # First argument. Should be 'true' or 'false'.
        echo 'save'
    } | xmllint --shell "app/etc/modules/$2.xml" # 2nd arg. Should be the filename without '.xml'
}

# Shortcuts so you don't have to type "true" and "false" all the time:

##
# Disable Magento module
magedismod() { magetogmod false "$1"; }

##
# Enable Magento module
mageenmod() { magetogmod true "$1"; }

Then you will need to clear cache if you have config cache turned on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM