In my site having two stores.I want to show store views select option in custom module in adminhtml.How to add functionality for that
asked Dec 14, 2016 at 11:55
User0434
1,1552 gold badges17 silver badges41 bronze badges
1 Answer 1
You can add field with this code
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabeld </label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
for get the value
const TEST_TEST_ENABLED = 'test/test/enabled';
protected $_scopeConfig;
public function __construct(
....
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
.....
$this->_scopeConfig = $scopeConfig;
....
}
public function getEnabled()
{
return $this->_scopeConfig->getValue(
self::TEST_TEST_ENABLED,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
answered Dec 14, 2016 at 12:33
Fme Extensions
1,4238 silver badges16 bronze badges
-
Whenever i select default config to other store view the module disable,for appear how to add in system.xmlUser0434– User04342016年12月14日 13:01:14 +00:00Commented Dec 14, 2016 at 13:01
-
@Nadh you want to add module disabled in system configuration?Fme Extensions– Fme Extensions2016年12月14日 13:04:32 +00:00Commented Dec 14, 2016 at 13:04
-
1i want to select option for particular storeUser0434– User04342016年12月14日 13:06:58 +00:00Commented Dec 14, 2016 at 13:06
-
you have to change
store viewof in configuration and values will be store for current store view you don't to add store view with that. you can get values\Magento\Store\Model\ScopeInterface::SCOPE_STOREfor current scope.Fme Extensions– Fme Extensions2016年12月14日 13:09:49 +00:00Commented Dec 14, 2016 at 13:09
default