How to create own cron-job in extension

test

New Member
How to override send-campaign command with ourself command. Maybe there are some possibility to kill core command and make own, and then when the cron job is running, it will work with own Class in extension not from the core.
 
@test - That is totally possible!

I advise you to extend the send-campaigns command instead of replacing it entirely.

Easiest way to do this is:
1. Create a file called MySendCampaignsCommand.php in apps/console/commands/ folder.
2. The file should have this content at least:
PHP:
<?php defined('MW_PATH') || exit('No direct script access allowed');

if ( ! class_exists( 'SendCampaignsCommand', false ) ) {
    require_once __DIR__ . '/SendCampaignsCommand.php';
}

class MySendCampaignsCommand extends SendCampaignsCommand
{
   
}

And inside the class you can override any functionality inherited from the original SendCampaignsCommand file.

Now, in order to make use of this code in your cron job, instead of calling send-campaigns call mysendcampaigns.
That's it.
 
Back
Top