I am trying to get the system configuration values but i have not found any solution.
please suggest how to get the config values fields like the below screenshot:
Solved! Go to Solution.
I have find a solution after several code trials. Please check the below example:
$config = $this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('section/group/field'); $values = (array)json_decode($config, true); $i = 0; foreach ($values as $value) { $start = $value['start_range']; $end = $value['end_range']; $percent = $value['mode']; }
Hello @Kiran ,
I can't see attached screenshot but I have given example to get the configuration field value
You've to change contact/email/recipient_email
class Dummy { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $scopeConfig; /** * Recipient email config path */ const XML_PATH_EMAIL_RECIPIENT = 'contact/email/recipient_email'; public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) { $this->scopeConfig = $scopeConfig; } /** * Sample function returning config value **/ public function getReceipentEmail() { $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; return $this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope); } }
Second thing
Create a function for getting configuration values in your custom module's helper.
public function getConfig($config_path) { return $this->scopeConfig->getValue( $config_path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); }
and call anywhere you want for example in test.phtml
$moduleStatus = $this->helper('Customvendorname\Custommodulename\Helper\Data')->getConfig('sectionid/groupid/fieldid');
--
if issue solved, please Accept as Solution & give Kudos
Please check the screenshot:
Hello @Kiran ,
Can you please let me know which extension are you using so I can see that and let you know.
If it's in default magento then give me path.
--
if issue solved, please Accept as Solution & give Kudos
It was just a field added by me in our custom module system.xml with its frontend_model a nd backend_model files..
I have find a solution after several code trials. Please check the below example:
$config = $this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('section/group/field'); $values = (array)json_decode($config, true); $i = 0; foreach ($values as $value) { $start = $value['start_range']; $end = $value['end_range']; $percent = $value['mode']; }
You should not use object manager.
love u -- for your fix
Actually, in my situation I wanted to do something like he suggested.