Hi am new to magento 2 and learning how to to create custom modules and i have added a option to enable disable from drop down and also added a config file but that seems to be not working. can anyone help me out.
am sharing my code:-
CONFIG.XML
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd">
<default>
<custom_module>
<general>
<enable>0</enable>
<title>Custom Customer Attribute</title>
</general>
</custom_module>
</default>
</config>
SYESTEM.XML
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
<system>
<tab id="mytab" translate="label" sortOrder="200">
<label>Eecom</label>
</tab>
<section id="custom_module" translate="label" type="text" sortOrder="300" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Custom Customer Attribute</label>
<tab>mytab</tab>
<resource>Eecom_CustomCustomerAttribute::config_custom_module</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="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Module</label>
<source_model>MagentoConfigModelConfigSourceYesno</source_model>
</field>
</group>
</section>
</system>
</config>
Helper/Data.php
<?php
/**
* Copyright © 2015 Eecom . All rights reserved.
*/
namespace EecomCustomCustomerAttributeHelper;
class Data extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @param MagentoFrameworkAppHelperContext $context
*/
public function __construct(MagentoFrameworkAppHelperContext $context
) {
parent::__construct($context);
}
public function isEnabled()
{
return (boolean) $this->getConfig('eecom_customcustomerattribute/general/enable');
}
}