How to get value from core_config_data table and set as default value in config.xml file in magento2












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>MagentoConfigModelConfigSourceYesno</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










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Please share system.xml file of this modules

    – Amit Bera
    Apr 4 '17 at 7:53











  • see this code... please help me.

    – Rohan Hapani
    Apr 4 '17 at 9:18
















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>MagentoConfigModelConfigSourceYesno</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










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Please share system.xml file of this modules

    – Amit Bera
    Apr 4 '17 at 7:53











  • see this code... please help me.

    – Rohan Hapani
    Apr 4 '17 at 9:18














1












1








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>MagentoConfigModelConfigSourceYesno</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










share|improve this question
















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>MagentoConfigModelConfigSourceYesno</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







magento2 adminhtml system-configuration






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 2 '17 at 12:43









Teja Bhagavan Kollepara

2,95841847




2,95841847










asked Apr 4 '17 at 7:33









Rohan HapaniRohan Hapani

1




1





bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Please share system.xml file of this modules

    – Amit Bera
    Apr 4 '17 at 7:53











  • see this code... please help me.

    – Rohan Hapani
    Apr 4 '17 at 9:18



















  • Please share system.xml file of this modules

    – Amit Bera
    Apr 4 '17 at 7:53











  • see this code... please help me.

    – Rohan Hapani
    Apr 4 '17 at 9:18

















Please share system.xml file of this modules

– Amit Bera
Apr 4 '17 at 7:53





Please share system.xml file of this modules

– Amit Bera
Apr 4 '17 at 7:53













see this code... please help me.

– Rohan Hapani
Apr 4 '17 at 9:18





see this code... please help me.

– Rohan Hapani
Apr 4 '17 at 9:18










1 Answer
1






active

oldest

votes


















0














You need include the MagentoStoreModelScopeInterface class consturctor



protected $_scopeConfig;

public function __construct(
...
MagentoStoreModelScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}


In Your specific place call:



$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE);





share|improve this answer



















  • 1





    $this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

    – Rohan Hapani
    Apr 4 '17 at 11:06











  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

    – Rohan Hapani
    Apr 4 '17 at 12:00






  • 1





    How can i set use this tab in other store view & store value in 'core_config_data' table ?

    – Rohan Hapani
    Apr 5 '17 at 4:37











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167511%2fhow-to-get-value-from-core-config-data-table-and-set-as-default-value-in-config%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You need include the MagentoStoreModelScopeInterface class consturctor



protected $_scopeConfig;

public function __construct(
...
MagentoStoreModelScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}


In Your specific place call:



$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE);





share|improve this answer



















  • 1





    $this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

    – Rohan Hapani
    Apr 4 '17 at 11:06











  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

    – Rohan Hapani
    Apr 4 '17 at 12:00






  • 1





    How can i set use this tab in other store view & store value in 'core_config_data' table ?

    – Rohan Hapani
    Apr 5 '17 at 4:37
















0














You need include the MagentoStoreModelScopeInterface class consturctor



protected $_scopeConfig;

public function __construct(
...
MagentoStoreModelScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}


In Your specific place call:



$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE);





share|improve this answer



















  • 1





    $this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

    – Rohan Hapani
    Apr 4 '17 at 11:06











  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

    – Rohan Hapani
    Apr 4 '17 at 12:00






  • 1





    How can i set use this tab in other store view & store value in 'core_config_data' table ?

    – Rohan Hapani
    Apr 5 '17 at 4:37














0












0








0







You need include the MagentoStoreModelScopeInterface class consturctor



protected $_scopeConfig;

public function __construct(
...
MagentoStoreModelScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}


In Your specific place call:



$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE);





share|improve this answer













You need include the MagentoStoreModelScopeInterface class consturctor



protected $_scopeConfig;

public function __construct(
...
MagentoStoreModelScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}


In Your specific place call:



$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE);






share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 4 '17 at 10:18









MartinsMartins

1448




1448








  • 1





    $this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

    – Rohan Hapani
    Apr 4 '17 at 11:06











  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

    – Rohan Hapani
    Apr 4 '17 at 12:00






  • 1





    How can i set use this tab in other store view & store value in 'core_config_data' table ?

    – Rohan Hapani
    Apr 5 '17 at 4:37














  • 1





    $this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

    – Rohan Hapani
    Apr 4 '17 at 11:06











  • its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

    – Rohan Hapani
    Apr 4 '17 at 12:00






  • 1





    How can i set use this tab in other store view & store value in 'core_config_data' table ?

    – Rohan Hapani
    Apr 5 '17 at 4:37








1




1





$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

– Rohan Hapani
Apr 4 '17 at 11:06





$this->scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .............. this value i want to stored in "general/store_information/name" using saveConfig() .... how it is possible?

– Rohan Hapani
Apr 4 '17 at 11:06













its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

– Rohan Hapani
Apr 4 '17 at 12:00





its solved : => put this below code in observer => execute() function $showTemplateHint = $this->_scopeConfig->getValue('general_tab/general/display_text', MagentoStoreModelScopeInterface::SCOPE_STORE); .................................. $this->resourceConfig->saveConfig('general/store_information/name', $showTemplateHint, 'default', 0);

– Rohan Hapani
Apr 4 '17 at 12:00




1




1





How can i set use this tab in other store view & store value in 'core_config_data' table ?

– Rohan Hapani
Apr 5 '17 at 4:37





How can i set use this tab in other store view & store value in 'core_config_data' table ?

– Rohan Hapani
Apr 5 '17 at 4:37


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167511%2fhow-to-get-value-from-core-config-data-table-and-set-as-default-value-in-config%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto