1

I cannot get my custom module to recognize my model.

AM/Cron/etc/config.xml

<?xml version="1.0"?>
<config>
        <modules>
                <AM_Cron>
                        <version>0.1.5</version>
                </AM_Cron>
        </modules>

        <global>
          <models>
                <AM_Cron>
                        <class>AM_Cron_Model</class> 
                </AM_Cron> 
          </models>

        </global>

        <crontab>
        <jobs>
            <AM_cron>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run><model>AM_Cron/checklockedurls::run</model></run>
            </AM_cron>
        </jobs>
        </crontab>
</config>

AM/Cron/model/Checklockedurls.php

<?php
class AM_Cron_Model_checklockedurls
{ 
    public function run()
    {
        return true;
    } 
}
  • What does the error say when you run getModel('AM_cron/checkLockedURLS')->run()? – musicliftsme Oct 14 '14 at 19:43
1

Try changing

To

<global>
  <models>
    <cron>
        <class>AM_Cron_Model</class> 
    </cron> 
  </models>

From

<global>
  <models>
    <AM_cron>
        <class>AM_Cron_checkLockedURLS</class> 
    </AM_cron> 
  </models>
  • I tried this to no avail. I have updated my original post with my latest code as I am getting the same error after trying @Amit's recommendation. – TylersSN Oct 15 '14 at 19:05
  • Change this to class AM_Cron_Model_Checklockedurls – Renon Stewart Oct 15 '14 at 19:13
1

There are lot of issue in config.xml

Issue1: Model class is not define.As per magento structure Basic model prefix define Model folder not up it class file :

Just Like :

YourModuleNamespace>YourModuleName>Model>

thus basic model prefix is

 YourModuleNamespace_YourModuleName_Model

So.

from

<global>
  <models>
    <AM_cron>
        <class>AM_Cron_checkLockedURLS</class> 
    </AM_cron> 
  </models>
</global>

to

<global>
  <models>
    <AM_cron>
    <!-- change here  -->
        <class>AM_Cron_Model</class> 
    </AM_cron> 
  </models>
</global>

issue2: you model file name checkLockedURLS.php is wrong it should be Checklockeurl.php.

As Magento logic names of files/folders after Model folder should be first letter is start with upper and then rest of name is lower letter

As you define AM_cron/checkLockedURLS::run in cron model

magento is split this like this

Check folder Locked > file Urls.php

That means magento give class for AM_cron/checkLockedURLS::run is

AM_Cron_Model_Check_Locked_Urls and it not match with you code

So change :

checkLockedURLS.php to Checklockedurls.php

then

AM_cron/checklockedURLS::run

to

AM_cron/checklockedurls::run

Config.xml as should name is config.xml

  • Thanks Amit, I have updated my original post with all of your changes but I am still getting the same error. Can you see where I may have goofed in your instructions? – TylersSN Oct 15 '14 at 19:04
  • I'm not sure if mix case will cause an issue see stackoverflow.com/questions/11547151/… – Renon Stewart Oct 15 '14 at 20:02
0

The directory "model" should have been "Model". After believing that I had double, triple quadruple checked cases, spelling, etc.. this slipped past me.

For my original post, the solutions provided did indeed help, but they would not take until I capitalized the Model directory.

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.