4

I've seen a few other questions about this with similar issues, but I can't seem to duplicate their fixes with my structure and Namespace/Moduel name etc.

I've got the following files:

Namespace/PendingCancellation/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_PendingCancellation>
            <version>0.1.0</version>
        </Namespace_PendingCancellation>
    </modules>
    <global>
        <models>
            <pendingcancellation>
                <class>Namespace_PendingCancellation_Model_Observer</class>
            </pendingcancellation>
        </models>
    </global>
    <crontab>
        <jobs>
            <PendingCancellation_Update>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run>
                    <model>pendingcancellation/observer::cancelPendingOrders</model>
                </run>
            </PendingCancellation_Update>
        </jobs>
    </crontab>
</config>

Namespace/PendingCancellation/Model/Observer.php

class Namespace_PendingCancellation_Model_Observer
{
    public function cancelPendingOrders()
    {
        Mage::log('Cron run', null, 'test.log');
    }
}

I know I'm likely doing something very obvious and or stupid but would very much appreciate the help after staring at this for a while.

3

You have declared your models incorrectly in config.xml:

<class>Namespace_PendingCancellation_Model_Observer</class>

should instead just be:

<class>Namespace_PendingCancellation_Model</class>

The string you enter here acts as starting point to find the location of the class according to how you refer to the model. So you have:

pendingcancellation/observer::cancelPendingOrders

in your cron job. The first thing that happens here is that the models relating to pendingcancellation are looked for, in your case you have declared your models resource as follows in config.xml:

...
<models>
    <pendingcancellation>
        <class>Namespace_PendingCancellation_Model_Observer</class>
    </pendingcancellation>
</models>
...

This means that Magento will use Namespace_PendingCancellation_Model_Observer as the start of the class name of your observer. After pendingcancellation you have observer. This makes up the rest of the class name, and so in this case translates to a class name of Namespace_PendingCancellation_Model_Observer_Observer which is not correct.

When declaring your resources in config.xml you should only ever declare the class name up to _Model/_Block/_Helper etc. as the rest of the class name is determined by the argument you send to the method which instantiates the class, which in this case is pendingcancellation/observer::cancelPendingOrders.

4
  • Ok, you're answer is waaay better. Great explanation!
    – Sander Mangel
    Dec 10 '14 at 11:38
  • I made the change, cleared out the cron_schedule table and ran cron.php a couple of times but it still doesn't appear to be being scheduled. Dec 11 '14 at 16:44
  • Are any other jobs not queueing? Dec 11 '14 at 16:48
  • Now that you mention it, not since I've cleared the schedule table, no nothing is queueing... Dec 15 '14 at 9:53
2

You used the full observer class in your global models tag. It should be

<global>
   <models>
      <pendingcancellation>
         <class>Namespace_PendingCancellation_Model</class>
      </pendingcancellation>
   </models>
</global>

Optionally, to debug cronjobs please check out https://github.com/AOEpeople/Aoe_Scheduler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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