This commit is contained in:
dimitar committed 2025-02-04 18:26:21 +01:00
1 parent 6086c048cd
commit 0b8c5de8b0
9 files changed
+876

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
<?php
class EcomZoneCronTask extends ModuleGrid
{
public function __construct()
{
parent::__construct();
$this->name = 'ecomzone_cron';
$this->title = $this->l('EcomZone Product Sync');
$this->cron_frequency = 3600 * 2; // Run every hour, change this to 2 hours!!!
}
public function install()
{
if (!parent::install()) {
return false;
}
Configuration::updateValue('ECOMZONE_LAST_CRON_RUN', '');
return true;
}
public function run()
{
try {
EcomZoneLogger::log('Starting scheduled product sync');
$productSync = new EcomZoneProductSync();
$result = $produgtSync->importProducts();
Configuration::updateValue('ECOMZONE_LAST_CRON_RUN', date('Y-m-d H:i:s'));
EcomZoneLogger::log('Scheduled product sync completed', 'INFO', $result);
return true;
} catch (Exception $e) {
EcomZoneLogger::log('Scheduled product sync failed', 'ERROR', ['error' => $e->getMessage()]);
return false;
}
}
}