How to get value from core_config_data table and set as default value in config.xml file in magento2
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>
magento2 adminhtml system-configuration
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.
add a comment |
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>
magento2 adminhtml system-configuration
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
add a comment |
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>
magento2 adminhtml system-configuration
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>
magento2 adminhtml system-configuration
magento2 adminhtml system-configuration
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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);
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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