Frankie Healy Frankie Healy - 7 months ago 26
PHP Question

Magento Cron Job Error - Invalid Callback

Im having some issues getting a cron job to work within Magentos cron system.

My module folder structure is as follows:

/app/code/local/Nnn/AbandonedCartEmails/etc/config.xml

/app/code/local/Nnn/AbandonedCartEmails/Model/Observer.php

My config xml is as follows:

<config>

<!--
The module's node contains basic
information about each Magento module
-->
<modules>
<!--
This must exactly match the namespace and module's folder
names, with directory separators replaced by underscores
-->
<Nnn_AbandonedCartEmails>

<!-- The version of our module, starting at 0.0.1 -->
<version>0.0.1</version>

</Nnn_AbandonedCartEmails>
</modules>

<global>
<!-- Defining models -->
<models>

<!--
Unique identifier in the model's node.
By convention, we put the module's name in lowercase.
-->
<nnn_abandonedcartemails>

<!--
The path to our models directory, with directory
separators replaced by underscores
-->
<class>Nnn_AbandonedCartEmails_Model</class>

</nnn_abandonedcartemails>

</models>
</global>

<crontab>
<jobs>
<nnn_abandonedcartemails>
<schedule>
<cron_expr>*/5 * * * *</cron_expr>
</schedule>
<run>
<model>abandonedcartemails/observer::processEmails</model>
</run>
</nnn_abandonedcartemails>
</jobs>
</crontab>




My observer class looks like this:

class Nnn_AbandonedCartEmails_Model_Observer
{
public function processEmails()
{

/***/


So the cron job is registering and is added to the cron_schedule table, however whenever it attempts to execute it produces and error along the lines of

exception 'Mage_Core_Exception' with message 'Invalid callback: abandonedcartemails/observer::processEmails does not exist' in /pathtosite/www/app/Mage.php:594


So it looks like I have a config issue, but I cant seem to see where the problem lies. The namespacing and naming conventions in Magento's xml files are quite frustrating to work with, so hopefully a fresh pair of eyes can see where I have made the mistake.

Any help always appreciated.

Thanks

Answer

Your model name is wrong.

In <model> tag, write <abandonedcartemails> instead of <nnn_abandonedcartemails>.

Your model is not calling. That is why this is error