Post by LeoZandvliet » Mon Aug 27, 2012 11:07 pm

Hey All,

Yes I know what cronjobs are and how to 'make' them, but I want to know how its done the best/cleanest way with Opencart.
I couldn't find any related topic on this site, so that's why I ask it here.

So: what is 'the best' method to make such?
Can it be routed through the default index.php ?
Or do I have to write a different script that includes index.php (or most of it) to 'initialize' the whole webshop-system?

Can someone point me in the right direction please?

Best regards,

Leo

I don't mass-sell webshops,
but knowledge and advice.
www.zandvlietwebconsultancy.nl


Newbie

Posts

Joined
Thu May 17, 2012 1:34 am
Location - Netherlands

Post by mrcnab » Wed Oct 17, 2012 4:22 am

Cron Job URL
Hi,
i'm using Open cart in my website.
i want to run a cron job for these urls
http://www.mywebsite.com/index.php?rout ... le_sitemap
http://www.mywebsite/index.php?route=fe ... inIndexXml

Can you help me. how to specify these into cron manager

Thanks

Newbie

Posts

Joined
Fri Oct 12, 2012 12:49 am

Post by Dr. Bogger » Sat Oct 27, 2012 6:37 am

LeoZandvliet wrote:Hey All,

Yes I know what cronjobs are and how to 'make' them, but I want to know how its done the best/cleanest way with Opencart.
I couldn't find any related topic on this site, so that's why I ask it here.

So: what is 'the best' method to make such?
Can it be routed through the default index.php ?
Or do I have to write a different script that includes index.php (or most of it) to 'initialize' the whole webshop-system?

Can someone point me in the right direction please?

Best regards,

Leo
I would also like to know this!

I am in the process of making a mod, that will send "Scheduled Emails" based on "Order Status", and if someone would share what the best way to make a cron job in opencart is, then I will release this as a free mod!

Thanks!

User avatar
Newbie

Posts

Joined
Sun Jul 15, 2012 7:01 am
Location - Saratoga Springs, NY

Post by SXGuy » Sat Oct 27, 2012 7:33 am

A Cron job, is only a string that is used to determine when it should call on a url.

It can be at any time, any hour, day, week, month etc

The actual URL needs to include a function which runs, when the url is accessed.

Think of it as though your the cron job and you type http://www.google.co.uk into a web browser

The page renders from the code on that page.

So if you create a mod where you want a order history mailed to you every x amount of times, days whatever.

You have to make sure that function runs when the page is called.

You have access to the database securely via opencart, so you only need to create pages in the standard mod way.

Controller, model and view files.

I would suggest you house these files in the public area i.e catalog not admin so you have no login token issues.

Add a rule to your robots.txt file to not allow crawling of those pages.

The controller file would need to call the mail function and grab the data from the model file.

The view template file, simply runs the command to send the mail, nothing else.

Then your cron job can call that page whenever you set it to.

Could be an easier way, someone else will know.

You can test it works by simply typing the url in to your web browser, you should then receive an email with the data you pulled from the database.

Your hosting control panel will allow you to set up a cron job

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ckonig » Wed Jul 17, 2013 9:52 pm

You might want to limit your cronjobs to a CLI execution, so nobody can start them from within their browser.
Example:

Code: Select all

if(php_sapi_name() != 'cli'){
   die('maandafrekening via web niet toegestaan'); 
}
Then you have actual control over how often your job is executed. For this solution, you will need a modified index.php that won't use $_SERVER['HTTP_HOST']
I have put this into a different directory, so now next to "Catalog" and "Admin" I also have a folder "Cron".

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by butte » Thu Aug 22, 2013 12:48 am

What ckonig suggested stands to prevent certain robots from triggering it in http, as well, causing runaway sessions, logs, etc., that tend to alarm hosts to the extent of shutting 'er down till somebody fixes 'er.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by miketramontano » Tue Jul 08, 2014 12:04 am

I've created a folder alongside admin and catalog in order to facilitate crons. It has a "bootstrap" that's basically a tweaked admin/index.php

http://stackoverflow.com/questions/2218 ... 0#24614760


Posts

Joined
Tue Jul 08, 2014 12:01 am

Post by openmandrake » Mon Mar 02, 2015 5:04 am

I have made a command line utility which (amongst others) solves this problem. The tool is called OCOK (Opencart OK) and can be installed in several ways (composer or phar download).

In the case of the cli task, simply a controller has to be created and put either in the admin or the catalog package. With the command line tool you can call the controller from the terminal. Additionally, a variable is provided which allows you to check if you are in cli mode or not. Also parameters can be provided via the terminal.

Feel free to try OCOK. Contact me if you have any problems or questions ;)

Checkout our extensions, or our open source projects


New member

Posts

Joined
Wed Oct 31, 2012 3:05 am
Who is online

Users browsing this forum: No registered users and 13 guests