createCronJob example

/** * Registers all required events for the similar shown articles function. */
    protected function subscribeSearchIndexEvents()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_SearchIndex',
            'getSearchIndexBackendController'
        );

        $this->createCronJob('Refresh search index', 'RefreshSearchIndex', 86400, true);
        $this->subscribeEvent('Shopware_CronJob_RefreshSearchIndex', 'refreshSearchIndex');
    }

    /** * Registers all required events for the also bought articles function. */
    protected function subscribeSeoIndexEvents()
    {
        $this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_Backend_Seo', 'getSeoBackendController');

        $this->subscribeEvent('Enlight_Bootstrap_InitResource_SeoIndex', 'initSeoIndexResource');
        
/** * Bootstrap Installation method * * @return bool */
    public function install()
    {
        $this->subscribeEvent(
            'Shopware_CronJob_ProductExport',
            'onRun'
        );
        $this->createCronJob('Product Export', 'ProductExport');

        return true;
    }

    public function onRun(Enlight_Components_Cron_EventArgs $job)
    {
        $this->exportProductFiles();

        return sprintf('%s succeeded.', $job->getName());
    }

    


class Migrations_Migration609 extends Shopware\Components\Migrations\AbstractMigration
{
    public function up($modus)
    {
        $this->addAlbum();
        $this->createCronJob();
    }

    private function createCronJob()
    {
        $sql = <<<SQL INSERT INTO s_crontab (`name`, `action`, `next`, `start`, `interval`, `active`, `end`, `pluginID`) VALUES ('Media Garbage Collector', 'MediaCrawler', now(), NULL, 86400, 0, now(), NULL) SQL;

        $this->addSql($sql);
    }

    
/** * Registers all required events for the similar shown articles function. */
    protected function subscribeSimilarShownEvents()
    {
        $this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_Backend_SimilarShown', 'getSimilarShownBackendController');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_SimilarShown', 'initSimilarShownResource');
        $this->subscribeEvent('Shopware_Plugins_LastArticles_ResetLastArticles', 'afterSimilarShownArticlesReset');
        $this->subscribeEvent('Shopware_Modules_Articles_Before_SetLastArticle', 'beforeSetLastArticle');

        $this->createCronJob('Similar shown article refresh', 'RefreshSimilarShown', 86400, true);
        $this->subscribeEvent('Shopware_CronJob_RefreshSimilarShown', 'refreshSimilarShown');
    }

    /** * Registers all required events for the also bought articles function. */
    protected function subscribeAlsoBoughtEvents()
    {
        $this->subscribeEvent('Shopware_Modules_Order_SaveOrder_ProcessDetails', 'addNewAlsoBought');
        $this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_Backend_AlsoBought', 'getAlsoBoughtBackendController');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_AlsoBought', 'initAlsoBoughtResource');
    }
$this->subscribeEvent(
            'Shopware_Plugins_HttpCache_InvalidateCacheId',
            'onInvalidateCacheId'
        );

        $this->subscribeEvent(
            'Shopware_Plugins_HttpCache_ClearCache',
            'onClearCache'
        );

        $this->createCronJob(
            'HTTP Cache löschen',
            'ClearHttpCache',
            86400,
            true
        );

        $this->subscribeEvent(
            'Shopware_CronJob_ClearHttpCache',
            'onClearHttpCache'
        );

        
Home | Imprint | This part of the site doesn't use cookies.