1

I want to add value from

BLOG > General > Store Information > Store name and set value in General > General > Store Information > Store name

which i added.

How it is possible? Please help me...

<?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="abc" translate="label" sortOrder="10">
            <label>abc</label>
        </tab>
        <section id="general_tab" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>General</label>
            <tab>abc</tab>
            <resource>abc_Blog::config_blog</resource>
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Store Information</label>
                <!-- <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Module Enable</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field> -->
                <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Store name</label>
                    <!-- <comment>This text will display on the frontend.</comment> -->
                </field>
                <field id="display_text2" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Store name2</label>
                    <!-- <comment>This text will display on the frontend.</comment> -->
                </field>
            </group>
        </section>
    </system>
</config>

enter image description here

2
  • Please share system.xml file of this modules
    – Amit Bera
    Apr 4, 2017 at 7:53
  • see this code... please help me. Apr 4, 2017 at 9:18

1 Answer 1

0

You need include the Magento\Store\Model\ScopeInterface class consturctor

protected $_scopeConfig;

public function __construct(
     ...
     \Magento\Store\Model\ScopeInterface $scopeInterface,
     ...
)
{
    ...
    $this->_scopeConfig = $scopeInterface;
    ...
}

In Your specific place call:

$this->scopeConfig->getValue('general_tab/general/display_text', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
3
  • 1
    $this->scopeConfig->getValue('general_tab/general/display_text', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible? Apr 4, 2017 at 11:06
  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0); Apr 4, 2017 at 12:00
  • 1
    How can i set use this tab in other store view & store value in 'core_config_data' table ? Apr 5, 2017 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.