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
NameSpace\Module\PHPFileWithMyClassbutNameSpace\Module\Model\PHPFileWithMyClass. Correctcrontab.xmland make sure namespace in php classes is correct (includingModelpart). – Zefiryn Dec 29 '17 at 17:56