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

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
asked Apr 4, 2017 at 7:33
2
  • Please share system.xml file of this modules Commented Apr 4, 2017 at 7:53
  • see this code... please help me. Commented 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);
answered Apr 4, 2017 at 10:18
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? Commented 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); Commented 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 ? Commented Apr 5, 2017 at 4:37

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.