Replace tags of html template of cron job from the extension


New Member
We have extension and its task is to replace some tags in campaigns' templates to some images. It should work when we start CRON Job command send-campaign. And in time of this running, we should change our custom tag to image. But the main point is to change tags during cron job is running and to make some changes to the SendCampaignsCommand without changing core only somehow override it with our extension.
@test = there are hooks in the send-campaigns command that helps you do this.
There is "console_command_send_campaigns_before_send_to_subscriber" which gets triggered right before the email is sent to the subscriber, after the rest of the tags where parsed, so your email template at this point will only have your custom tag in it which is unparsed.
You can connect to this filter like:
Yii::app()->hooks->addFilter('console_command_send_campaigns_before_send_to_subscriber', function(
$emailParams, $campaign, $subscriber, $customer, $server
    $emailParams['body'] = str_replace('[WHATEVER]', '<img src=".."/>', $emailParams['body']);
    return $emailParams;

if you open /apps/console/commands/SendCampaignsCommand.php and look for calls to:
You will see lots of hooks to which you can connect to from extensions.