1

As the title suggests I'm having some trouble targeting three custom classes I want to run on a schedule. The crontab.xml below returns the following error:

PHP Fatal error:  Uncaught Error: Class 'NameSpace\Module\PHPFileWithMyClass' not found in /var/www/domain.com/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:93

crontab.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="default">
        <job name="job-name" instance="NameSpace\Module\PHPFileWithMyClass" method="execute" >
            <config_path>crontab/default/jobs/config_path_works/schedule/cron_expr</config_path>
        </job>
        <job name="job-name2" instance="NameSpace\Module\PHPFileWithMyClass2" method="execute" >
            <config_path>crontab/default/jobs/config_path_works/schedule/cron_expr</config_path>
        </job>
        <job name="mjob-name3" instance="NameSpace\Module\PHPFileWithMyClass3" method="execute" >
            <config_path>crontab/default/jobs/config_path_works/schedule/cron_expr</config_path>
        </job> 
    </group>
</config>

My file structure is as follows:

NameSpace
-/Module/
--/etc/
---crontab.xml
--/Model/
---PHPFileWithMyClass.php
---PHPFileWithMyClass2.php
---PHPFileWithMyClass3.php
6
  • Please make the the name unique for each cron and check in schedule cron table Commented Dec 29, 2017 at 17:54
  • It looks like your classes are not NameSpace\Module\PHPFileWithMyClass but NameSpace\Module\Model\PHPFileWithMyClass. Correct crontab.xml and make sure namespace in php classes is correct (including Model part).
    – Zefiryn
    Commented Dec 29, 2017 at 17:56
  • @PurushotamSharma, I'm sorry, that was my mistakes. In my code the job names are unique. In the cron table they're showing that the class can't be found. Commented Dec 29, 2017 at 17:58
  • @Zefiryn, I'm the front end developer trying to troubleshoot a back end issue. My back end developer told me that "Model" should be omitted from the class name? Commented Dec 29, 2017 at 17:59
  • Please check my answer here magento.stackexchange.com/questions/207480/… Commented Dec 29, 2017 at 17:59

0

Your Answer

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

Browse other questions tagged or ask your own question.