cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the configuration field values

SOLVED

how to get the configuration field values

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:
Screenshot from 2019-02-06 18-41-00.png

1 ACCEPTED SOLUTION

Accepted Solutions

Re: how to get the configuration field values

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'];
}

View solution in original post

8 REPLIES 8

Re: how to get the configuration field values

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

Re: how to get the configuration field values

Please check the screenshot:
Screenshot from 2019-02-06 18-41-00.png

Re: how to get the configuration field values

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

Re: how to get the configuration field values

It was just a field added by me in our custom module system.xml with its frontend_model a nd backend_model files..

Re: how to get the configuration field values

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'];
}

Re: how to get the configuration field values

You should not use object manager.

Re: how to get the configuration field values

love u -- for your fixHeart

Re: how to get the configuration field values

Actually, in my situation I wanted to do something like he suggested.