且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento:禁用任何特定商店的模块

更新时间:2023-11-30 13:20:46

这个配置只是禁用前端布局模块输出,但模块控制器,事件观察器,管理页面等仍在工作。



也不要忘记在布局文件定义中指定模块名称,否则将为特定商店加载所有布局文件内容:

 < config> 
< layout>
< module_alias module =Module_Name>
< file> yourlayoutfile.xml< / file>
< / module_alias>
< / layout>
< / config>

如果您正在开发一个模块并想要禁用其特定商店的前端功能,那么您应该创建一个Yes / No类型的配置字段,并通过模块代码中的Mage :: getStoreConfigFlag('config / field / path')检查其值。


Suppose, I have 3 stores.

I want to disable a module in Store 2. I only want it to be enabled in Store 1 and Store 3.

I see that I can do it by:-

  • Going to System -> Configuration -> Advanced

  • Selecting desired store from Current Configuration Scope dropdown list.

But this does not work fully.

And, I also don't want to check store in the module code itself or create system configuration field for the module to check/uncheck store to enable/disable.

What I am expecting is by adding some code in app/etc/modules/MyNamespace_MyModule.xml. Can we do it this way?

This configuration just disables module output in layout for frontend, but module controllers, event observers, admin pages, etc still working.

Also don't forget to specify your module name in layout files definition, otherwise all the layout file content will be loaded for a particular store:

<config>
   <layout>
       <module_alias module="Module_Name">
           <file>yourlayoutfile.xml</file>
       </module_alias>
   </layout>
</config>

If you are developing a module and want to disable full its functionality on the frontent for a particular store, then you should create a configuration field of "Yes/No" type and check its value via Mage::getStoreConfigFlag('config/field/path') in your module code.