Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
- <system>
- <tab id="mymodule" translate="label" sortOrder="100">
- <label>My Module</label>
- </tab>
- <section id="mymodule" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
- <label>My Module</label>
- <tab>myconfig</tab>
- <resource>Vendor_Module::system_config</resource>
- <group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
- <label>General Configuration</label>
- <field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
- <label>Enable Module</label>
- <source_model>MagentoConfigModelConfigSourceEnabledisable</source_model>
- </field>
- </group>
- </section>
- </system>
- </config>
- class Myclass
- {
- public function __construct(
- MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
- ){
- $this->scopeConfig = $scopeConfig;
- }
- public function isModuleEnabled($website = null)
- {
- return $this->scopeConfig->isSetFlag(
- 'mymodule/general/enable',
- MagentoStoreModelScopeInterface::SCOPE_WEBSITE,
- $website
- );
- }
- public function execute()
- {
- if ($this->isModuleEnabled()) {
- // Do stuff here if module is enabled.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement