Here’s my controller.
public function mockcron_newmatchAction(){
$task = Mage::getModel('showdown/cron::makematch');
var_dump($task);
}
And here’s the cron function located at app/code/local/Desbest/Showdown/Model
<?php
class Desbest_Showdown_Model_Cron
{
public function makematch(){
$var = "apples";
return $var;
}
}
The problem is that $task = Mage::getModel('showdown/cron::makematch'); does not run and I want that model to run. What do I do?
The variable prints as false, regardless of whether I have chosen an existing model or not.
The
::syntax only works if you’re providing a source model in asystem.xmlXML.It doesn’t work when you’re writing regular PHP code. The syntax you want is
The call to
Mage::getModel('showdown/cron')instantiates your model object, and then the->makematch();calls a method, as per standard PHP. When you sayyou’re asking magento to instantiate the class with an alias of
showdown/cron::makematch. Since that’s an invalid alias alias, this will always return false.