Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 04-30-2024 10:49:10

Registered: 04-29-2024
Posts: 77

Cron Job Code Issue

NOTE: This post was created on 2023-10-13 on the Kryptronic eCommerce Community facebook page, which has been replaced with this forum.  All facebook support content was migrated into this forum in April 2024.


Any reason why $this->exec_namespace won't work when run inside a tasks_hourly cron job?

If I use the exact same lines of code within another frontend function, they work as expected. The cronjob also works correctly if I take out the $this->exec_namespace line of code.

The namespace is a new function that grabs the  analytics data from google and updates the order table. Everything works fine, but I need to manually run the function as I can't get it to run via a cronjob.


I am assuming you put that cron job in {private}/core/CORE/tasks_hourly and based it off of another job there. Please be aware that cron executing via the CORE have classes that extend CORE. Crons executing via applications (like {private}/apps/ecom/ECOM/tasks_hourly) extend their base application classes (like ECOM, CMS).

The exec_namespace() function is part of CORE_App. Since your cron file is extending CORE, CORE_App is not part of the chain, and exec_namespace (which is part of CORE_App) is not available. If you were to have put that cron file in an application, you would be extending either CMS or ECOM, which both extend CORE_App, so that would work there.

I hope that makes sense. Your fix is to load up CORE_App in your constructor or exec function:
$this->CORE_App =& $this->quick_object('CORE_App','core');

Then call the exec_namespace function like this:



I am putting the cron job in ecom/ECOM/tasks_hourly. I think CORE_APP is available as it is used in 0400_paypalcp.php. I will try loading CORE_App and then calling it with CORE_App->exec_namepace


Hi Rob,
I am running a script in ecom/ECOM/tasks_twelfthhourly that uses:-
Without adding in the CORE_APP explicitly and everything is working fine. Maybe a good idea to check the call to the namespace is correct. To test stuff I usually create a test page and then use
$test = $this->include_namespace(...
Can then do things with $test to see what happened and make sure things are working as expected.



Board footer