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
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
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
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
I would also like to know this!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 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!
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
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
You might want to limit your cronjobs to a CLI execution, so nobody can start them from within their browser.
Example:
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".
Example:
Code: Select all
if(php_sapi_name() != 'cli'){
die('maandafrekening via web niet toegestaan');
}
I have put this into a different directory, so now next to "Catalog" and "Admin" I also have a folder "Cron".
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
http://stackoverflow.com/questions/2218 ... 0#24614760
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
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
Who is online
Users browsing this forum: No registered users and 14 guests