Cron script Prestashop (php)

I need to make a cron script ('cron_script.php') that updates a XML. The static functions that make this are defined in my main module class 'xmlmodule.php'.

My problem is the cron script doesn't run module class with 'require' or 'require_once'. The prestashop configuration values are not loaded in script so is always exiting. If I comment the 'if' statement for check '_PS_VERSION_' I have an error output because is not finding the 'Module' class.

Here is my module main class ('xmlmodule.php'):

<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class XmlModule extends Module {
    //Module functions
}

And this is my cron script:

<?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

I'm executing it locally with curl and crontab and my PrestaShop version is 1.6 with PHP7.0. I know about modules use cron scripts but I can find anything of code for see how to do it.

Does anyone know? Thanks a lot.


ANSWERS:


I guess you could try including these prestashop files inside your xmlmodule.php

$site_base_path="./";
require_once($site_base_path . 'config/config.inc.php'); 
require_once($site_base_path . 'init.php');

This way, your script will have access to all the neede prestashop classes , constants etc.


in PrestaShop cron always add at the beginning:

include(dirname(__FILE__).'/../../config/config.inc.php');

If the cron is module is fine as I wrote it, or increase or decrease the "../" directory.

With that include the function of PrestaShop global functions and variables



 MORE:


 ? How to find .tpl file of navbar
 ? Prestashop Geoip module - missing country
 ? Using PHP code in Smarty tpl FIle
 ? Create custom page in Prestashop 1.5.3
 ? How to create a new page in prestashop admin panel?
 ? Confused about prestashop PDF generated process. Where is the code to handle the logic?
 ? How to integrate prestashop with android?
 ? Create product from a module in prestashop
 ? Acces Prestashop webservice from JavaScript
 ? add a field in edit product page of prestashop admin