0

I am facing issue to create module. I created one module and I given apply to system admin to enable disable. So, Right now I am doing module hide/show using below code.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$module_enable = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('magefilter/magefilter/enable');
if(isset($module_enable) && $module_enable==1){

but is there any way if I can disable module from admin then it is disable by xml file.

I means is there any way to not ovverride that xml.

Thanks

  • Hi, This is just suggestion instead you think to set condition in the XML file you can create Helper and create a function that will check the module enable condition so that you can use anywhere in the project. – Praveen Chelumalla Nov 20 '19 at 6:46
  • @PraveenChelumalla actually I override some XML file based on install-module. Once I install the module then XML is overridden. It does not depend on the admin enable/disable option. So, I want to XML depend on the admin option. is there any way? – sarvesh Dineshkumar Patel Nov 20 '19 at 6:49
  • Okay, then I also need to research this thing. – Praveen Chelumalla Nov 20 '19 at 6:52
  • try ifconfig in your xml block – Sukumar Gorai Nov 20 '19 at 8:32
  • @SukumarGorai how ? – sarvesh Dineshkumar Patel Nov 20 '19 at 9:04
0

You can find your module from here 'app/etc/config.php' and replace 1 to 0 then it will be disabled. Clean cache

Hope it works for you.

  • Thanks, bro. But I don't want to disable the module from everywhere. I just disable for the front side. thanks – sarvesh Dineshkumar Patel Nov 20 '19 at 9:54
0

Please go to your directory and find 'app/etc/config.php

If you want disable module just replace 1 to 0. For your check our below example.

'Developer_Categoryimages' => 1, Replace To 'Developer_Categoryimages' => 0

After that flush Magento Cache.

  • thanks but I do not want like that. If I Disable from admin then configuration page and then disable from the only front side. I mean no-load XML and CSS or anything in front. – sarvesh Dineshkumar Patel Nov 22 '19 at 12:36
0

Please go to your directory and find 'app/etc/config.php

If you want disable module just replace 1 to 0. For your check our below example.

'Developer_Categoryimages' => 1, Replace To 'Developer_Categoryimages' => 0

open the terminal and navigate to Magento webroot.

$ cd /var/www/html/magento2

$ php bin/magento setup:upgrade

$ php bin/magento setup:static-content:deploy

$ cd generated

$ chmod -R 777 /var/www/html/magento2/generated

$ php bin/magento cache:flush

0

if you want to used only XML file for Enable and Disable Module. you have to Used ifconfig in Block conteiner and Refernece Container.

<block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="config_path/group/field" before="category.products"/>

<move element="category.image" destination="content" ifconfig="config_path/group/field" before="-"/>

and what is ifconfig value and how it's come click here

Reference link

I Hope This Helps You.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.