1

I am trying to make a custom module to run a cron job to assign products to categories.

I am however missing something, and I keep getting errors, and the cron job shows up, but doesn't work.

/public_html/app/code/local/Firmname/Catcron/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Firmname_Catcron>
            <version>1.0</version>
        </Firmname_Catcron>
    </modules>

    <global>
        <models>
            <firmname_catcron>
                <class>Firmname_Catcron_Model</class>
            </firmname_catcron>                         
        </models>
    </global>

    <crontab>
        <jobs>
            <firmname_catcron>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run><model>Firmname_catcron/observer::crontask</model></run>
            </firmname_catcron>
        </jobs>
    </crontab>
</config>

/public_html/app/code/local/Firmname/Catcron/Model/Observer.php

<?php

class Firmname_Catcron_Model_Observer {
  public function crontask() {
        // code
    }
}

/public_html/app/etc/modules/Firmname_Catcron.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Firmname_Catcron>
      <active>true</active>
      <codePool>local</codePool>
    </Firmname_Catcron>
  </modules>
</config>

The error:

---EXCEPTION--- Mage_Core_Exception: Invalid callback: Model for Firmname_catcron/observer::crontask does not exist in /var/www/mysite.com/public_html/app/Mage.php:598 Stack trace:

0 /var/www/mysite.com/public_html/app/code/community/Aoe/Scheduler/Helper/Data.php(298):

Mage::throwException('Invalid callbac...')

1 /var/www/mysite.com/public_html/app/code/community/Aoe/Scheduler/Model/Job.php(143):

Aoe_Scheduler_Helper_Data->getCallBack('Firmname_catcron/...')

2 /var/www/mysite.com/public_html/app/code/community/Aoe/Scheduler/Model/Schedule.php(192):

Aoe_Scheduler_Model_Job->getCallback()

3 /var/www/mysite.com/public_html/app/code/community/Aoe/Scheduler/Model/Schedule.php(582):

Aoe_Scheduler_Model_Schedule->runNow(true)

4 /var/www/mysite.com/public_html/app/code/community/Aoe/Scheduler/Model/Observer.php(39):

Aoe_Scheduler_Model_Schedule->process()

5 /var/www/mysite.com/public_html/app/code/core/Mage/Core/Model/App.php(1358):

Aoe_Scheduler_Model_Observer->dispatch(Object(Varien_Event_Observer))

6 /var/www/mysite.com/public_html/app/code/core/Mage/Core/Model/App.php(1337):

Mage_Core_Model_App->_callObserverMethod(Object(Aoe_Scheduler_Model_Observer), 'dispatch', Object(Varien_Event_Observer))

7 /var/www/mysite.com/public_html/app/Mage.php(451): Mage_Core_Model_App->dispatchEvent('default', Array)

8 /var/www/mysite.com/public_html/cron.php(83): Mage::dispatchEvent('default')

9 {main}

I really hope someone has an idea as to why I am struggling so much to get my module to work!

1 Answer 1

1

Your alias for model is firmname_catcron and you call the cron with

<run><model>Firmname_catcron/observer::crontask</model></run>

I guess the uppercase F of Firmname instead of firmname could be the source of your issue.

Please, try with :

<run><model>firmname_catcron/observer::crontask</model></run>
1
  • That was the solution in my case! I can't believe i missed that one. Many thanks for your help! Dec 18, 2019 at 13:54

Your Answer

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

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