1

I get the error above for some reason when I try to manually execute the /cron.php file.

Here is my config.xml for a module that I think is causing the issue

<?xml version="1.0" encoding="UTF-8"?>

<!-- The root node for Magento module configuration -->
<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
        -->
        <Company_ScheduledPriceDrop>

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

        </Company_ScheduledPriceDrop>

    </modules>

    <crontab>
        <jobs>
            <Company_ScheduledPriceDrop>
                <schedule>
                    <cron_expr>*/5 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>Company_ScheduledPriceDrop/observer::setPrice</model>
                </run>
            </Company_ScheduledPriceDrop>
        </jobs>
    </crontab>

</config>

And here is the observer file that is being called

<?php

class Company_ScheduledPriceDrop_Model_Observer extends Mage_Core_Model_Abstract
{
   public function setPrice()
   { 
        Mage::log("WORKS!");
   }
}

I'm not sure what the error means, can anyone help please?

Burt
  • 7,680
  • 18
  • 71
  • 127

2 Answers2

2

\app\etc\modules\Company_ScheduledPriceDrop.xml, \app\code\local\Company\ScheduledPriceDrop\etc\config.xml, and \app\code\local\Company\ScheduledPriceDrop\Model\Observer.php should be your files.

Company_ScheduledPriceDrop.xml

<config>
    <modules>
        <Company_ScheduledPriceDrop>
            <active>true</active>
            <codePool>local</codePool>
        </Company_ScheduledPriceDrop>
    </modules>
</config>

This file tells Magento that you have a module to load.

config.xml

<config>
    <modules>
        <Company_ScheduledPriceDrop>
            <version>1.0.0</version>
        </Company_ScheduledPriceDrop>
    </modules>
    <global>
        <models>
            <scheduledpricedrop>
                <class>Company_ScheduledPriceDrop_Model</class>
            </scheduledpricedrop>                         
        </models>
    </global>
    <crontab>
        <jobs>
            <scheduledpricedrop>
                <schedule>
                    <cron_expr>*/5 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>scheduledpricedrop/observer::setPrice</model>
                </run>
            </scheduledpricedrop>
        </jobs>
    </crontab>
</config>

This file tells Magento where the module plugs in to the Magento system.

Also.. you need to have your models in the global namespace for cron stuff. Hope this helps!

If that still doesn't work, please post the full error output by Magento and I'll update the answer.

Also here, have this How to setup a cron job in Magento module?

Community
  • 1
  • 1
Nick M
  • 429
  • 4
  • 10
1
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Company_Schedule>
            <version>0.0.1</version>
        </Company_Schedule>
    </modules>

    <global>
        <models>
            <schedule>
                <class>Company_Schedule_Model</class>
            </schedule>
        </models>
    </global>

    <crontab>
        <jobs>
            <schedulepricedrop_cronjob>
                <schedule>
                    <cron_expr>*/5 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>schedule/observer::setPrice</model>
                </run>
            </schedulepricedrop_cronjob>
        </jobs>
    </crontab>

</config>

It works for me. Select from cron_schedule:

100     schedulepricedrop_cronjob   pending     NULL    2015-04-10 05:22:11     2015-04-10 05:25:00     NULL    NULL
101     schedulepricedrop_cronjob   pending     NULL    2015-04-10 05:22:11     2015-04-10 05:30:00     NULL    NULL
102     schedulepricedrop_cronjob   pending     NULL    2015-04-10 05:22:11     2015-04-10 05:35:00     NULL    NULL
103     schedulepricedrop_cronjob   pending     NULL    2015-04-10 05:22:11     2015-04-10 05:40:00     NULL    NULL
zhartaunik
  • 932
  • 12
  • 29