1

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

1 Answer 1

2

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
4
  • Whenever i select default config to other store view the module disable,for appear how to add in system.xml Commented Dec 14, 2016 at 13:01
  • @Nadh you want to add module disabled in system configuration? Commented Dec 14, 2016 at 13:04
  • 1
    i want to select option for particular store Commented Dec 14, 2016 at 13:06
  • you have to change store view of 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_STORE for current scope. Commented Dec 14, 2016 at 13:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.