1

in Magento 2, I want to get value of "Generate Schedules Every" text box location under

Admin->STORES->ADVANCED->System->Cron (Scheduled Tasks)->Cron configuration options for group: default

Want this value in controller. Can anyone tell me how can we get this?

Thank you in advance!

1

Try this

protected $_scopeConfig;

public function __construct(
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
    $this->_scopeConfig = $scopeConfig;
}

public function getConfig($config_path)
{
    return $this->_scopeConfig->getValue(
        $config_path,
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    );
}

public function execute() {

$schedule_generate_every = $this->getConfig('system/cron/default/schedule_generate_every');
$schedule_ahead_for = $this->getConfig('system/cron/default/schedule_ahead_for');
$schedule_lifetime = $this->getConfig('system/cron/default/schedule_lifetime');
$history_cleanup_every = $this->getConfig('system/cron/default/history_cleanup_every');
$history_success_lifetime = $this->getConfig('system/cron/default/history_success_lifetime');
$history_failure_lifetime = $this->getConfig('system/cron/default/history_failure_lifetime');
$use_separate_process = $this->getConfig('system/cron/default/use_separate_process');

}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.