【发布时间】:2017-08-25 11:13:45
【问题描述】:
我需要制作一个更新 XML 的 cron 脚本 ('cron_script.php')。实现这一点的静态函数在我的主模块类“xmlmodule.php”中定义。
我的问题是 cron 脚本没有运行带有 'require' 或 'require_once' 的模块类。 prestashop 配置值未在脚本中加载,因此始终退出。如果我评论检查“_PS_VERSION_”的“if”语句,我有一个错误输出,因为没有找到“模块”类。
这是我的模块主类('xmlmodule.php'):
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class XmlModule extends Module {
//Module functions
}
这是我的 cron 脚本:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
echo "Before require once </br>";
require_once('xmlmodule.php'); //This exits the script
echo "<h2>Prueba CRON updateFeed</h2>"; //Never executed
我使用 curl 和 crontab 在本地执行它,而我的 PrestaShop 版本是 1.6,使用 PHP7.0。我知道模块使用 cron 脚本,但我可以找到任何代码来看看如何去做。
有人知道吗?非常感谢。
【问题讨论】:
标签: php cron prestashop crontab prestashop-1.6