1

I would like to take the value of the ahead schedule of this system.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
 <section id="system">
 <group id="cron" translate="label comment" type="text" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Cron (Scheduled Tasks)</label>
 <comment>For correct URLs generated during cron runs please make sure that Web &gt; Secure and Unsecure Base URLs are explicitly set. All the times are in minutes.</comment>
 <group id="template" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Cron configuration options for group: </label>
 <field id="schedule_generate_every" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Generate Schedules Every</label>
 </field>
 <field id="schedule_ahead_for" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Schedule Ahead for</label>
 </field>
 <field id="schedule_lifetime" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Missed if Not Run Within</label>
 </field>
 <field id="history_cleanup_every" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>History Cleanup Every</label>
 </field>
 <field id="history_success_lifetime" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Success History Lifetime</label>
 </field>
 <field id="history_failure_lifetime" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Failure History Lifetime</label>
 </field>
 <field id="use_separate_process" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
 <label>Use Separate Process</label>
 <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
 </field>
 </group>
 </group>
 </section>
</system>

I tried this command in a controller

$scheduleAheadFor = $this->scopeConfig->getValue('system/cron/schedule_ahead_for', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

but it did not work. Someone who can help me?

asked Aug 8, 2019 at 9:18

1 Answer 1

2

It seems you are missing the template part from the config path. Try this:

$scheduleAheadFor = $this->scopeConfig->getValue('system/cron/template/schedule_ahead_for', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

answered Aug 8, 2019 at 9:20
2
  • is the first thing that I thought too. I tried $ this-> scopeConfig-> getValue ('system / cron / template / schedule_ahead_for', Magento Store ScopeInterface :: SCOPE_STORE); but returns null. Commented Aug 8, 2019 at 9:30
  • 1
    You need to replace template with your cron's group id Commented Aug 8, 2019 at 9:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.