diff --git a/class/preisbot.class.php b/class/preisbot.class.php index f8d5861..22c8122 100755 --- a/class/preisbot.class.php +++ b/class/preisbot.class.php @@ -54,9 +54,19 @@ class PreisBot { global $conf, $user, $langs; + // Sicherheits-Timeout: Max 5 Minuten für den gesamten Job + @set_time_limit(300); + try { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + // User-Kontext sicherstellen (Cronjob hat manchmal keinen User) + if (empty($user) || !is_object($user) || empty($user->id)) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user = new User($this->db); + $user->fetch(1); // Admin-User + } + $priceSource = getDolGlobalString('PREISBOT_PRICE_SOURCE', 'cheapest'); $priceDirection = getDolGlobalString('PREISBOT_PRICE_DIRECTION', 'up_only'); $minMargin = (float) getDolGlobalString('PREISBOT_MIN_MARGIN', 20);