Reputation: 125
Can anyone help me, I have a number of models that run on cron and I want to be able to execute on demand
How can I create a button on a layout file or template file that executes the model code?
Kind regards
Upvotes: 0
Views: 71
Reputation: 15216
I can recommend you this extension. http://www.magentocommerce.com/magento-connect/aoe-scheduler.html. It allows you to see the crons you have set, enable and disable them and even run them manually when ever you want. You can do all of that from a single page in the backend.
If you want to add a button that runs your script in a certain page (other than the one in the extension above) you need to create a controller and an action, put a simple button or link in the template you want that points to the action you just created.
In that action you just need to execute the method from the model that is executed by the cron.
public function someAction() {
Mage::getModel('some/model')->someAction(); //add params if needed
//at the end do a redirect.
}
Upvotes: 2