Post by Cue4cheap » Wed Jan 12, 2022 12:15 pm

Opencart 3.1. alpha did have a cron feature but it looks like it is gone in 3.0.2.x+
But as I try to go forward and build my test site using 3.0.3.8 I need a cron-like feature to run an admin script. How would this be possible in 3.0.3.8?
Now if someone suggests an event I'll kindly ask how the admin event would get kicked off? To add info to that question let me say my store is set up in such a way that I do not need to log into the admin side every day. As I understand it, an admin events would require the admin to be logged into, correct or not?

Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by OSWorX » Wed Jan 12, 2022 12:50 pm

Cue4cheap wrote:
Wed Jan 12, 2022 12:15 pm
Opencart 3.1. alpha did have a cron feature but it looks like it is gone in 3.0.2.x+
OC 3.1.x is the preprocessor of the current OC 4.x branch.
And has nothing todo with OC 3.x
Cue4cheap wrote:
Wed Jan 12, 2022 12:15 pm
But as I try to go forward and build my test site using 3.0.3.8 I need a cron-like feature to run an admin script. How would this be possible in 3.0.3.8?
Now if someone suggests an event I'll kindly ask how the admin event would get kicked off? To add info to that question let me say my store is set up in such a way that I do not need to log into the admin side every day. As I understand it, an admin events would require the admin to be logged into, correct or not?
Cron: either define a cronjob (on your server or by an external service - enough free on the market) which is calling the backend (admin) function (or frontend function) - no need for any event.
Or do the same with an event (and further script in the backend) for the frontend (e.g. header) - but that requires that you have visitors ..

We do such similiar at some clients with data from external sources to update the product (stock, etc.).
Mostly via frontend functions (they can do the same as evey backend script).

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by thekrotek » Wed Jan 12, 2022 2:38 pm

Always use the server's cron job.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by OSWorX » Wed Jan 12, 2022 3:02 pm

thekrotek wrote:
Wed Jan 12, 2022 2:38 pm
Always use the server's cron job.
Naturally, but I've seen some providers not offering them.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by paulfeakins » Wed Jan 12, 2022 7:20 pm

OSWorX wrote:
Wed Jan 12, 2022 3:02 pm
thekrotek wrote:
Wed Jan 12, 2022 2:38 pm
Always use the server's cron job.
Naturally, but I've seen some providers not offering them.
In that case you can use something like: https://www.easycron.com/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Cue4cheap » Wed Jan 12, 2022 8:51 pm

I don't get how it works calling the admin script using my hosts cron. What about admin log in?
For 2.3.0.2 I had to use this: https://github.com/iSenseLabs/oc_cli (Which BTW works very well.)
Does OC 3.0.3.8 not have a need for this same work around?
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Wed Jan 12, 2022 8:57 pm

Cue4cheap wrote:
Wed Jan 12, 2022 8:51 pm
I don't get how it works calling the admin script using my hosts cron. What about admin log in?
For 2.3.0.2 I had to use this: https://github.com/iSenseLabs/oc_cli (Which BTW works very well.)
Does OC 3.0.3.8 not have a need for this same work around?
Mike
OC v3.0.3.8 does not have this same workaround. The best option would be to use the domain one offered by your host. If you're not sure if your host does provide that feature, contact their support lines and, if they do offer it, get the cron path in order to initiate your crons on your PHP files. The reason why it may not always be provided by your host is based on the hosting plans being offered and purchased.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Cue4cheap » Wed Jan 12, 2022 9:06 pm

straightlight wrote:
Wed Jan 12, 2022 8:57 pm
Cue4cheap wrote:
Wed Jan 12, 2022 8:51 pm
I don't get how it works calling the admin script using my hosts cron. What about admin log in?
For 2.3.0.2 I had to use this: https://github.com/iSenseLabs/oc_cli (Which BTW works very well.)
Does OC 3.0.3.8 not have a need for this same work around?
Mike
OC v3.0.3.8 does not have this same workaround. The best option would be to use the domain one offered by your host. If you're not sure if your host does provide that feature, contact their support lines and, if they do offer it, get the cron path in order to initiate your crons on your PHP files. The reason why it may not always be provided by your host is based on the hosting plans being offered and purchased.

My host offers cron and I use it now. My question is the admin authentication to run an admin side script. Admin scripts need to have you log into admin to run, right?
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by Cue4cheap » Thu Jan 13, 2022 7:35 am

OSWorX wrote:
Wed Jan 12, 2022 12:50 pm
Cron: either define a cronjob (on your server or by an external service - enough free on the market) which is calling the backend (admin) function (or frontend function) - no need for any event.
Or do the same with an event (and further script in the backend) for the frontend (e.g. header) - but that requires that you have visitors ..

We do such similiar at some clients with data from external sources to update the product (stock, etc.).
Mostly via frontend functions (they can do the same as evey backend script).
How do you call an admin side script via webhost cron when admin scripts require username / login?
Do you have this working? If so what is the mechanism you use to bypass the username/login requirement?

Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by Cue4cheap » Thu Jan 13, 2022 7:37 am

I'll give this one a shot when I duplicate the 3.0.3.8 I'm building. I don't wish to 'muddy' my new (clean) build.
Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Thu Jan 13, 2022 9:15 am

Cue4cheap wrote:
Thu Jan 13, 2022 7:35 am
OSWorX wrote:
Wed Jan 12, 2022 12:50 pm
Cron: either define a cronjob (on your server or by an external service - enough free on the market) which is calling the backend (admin) function (or frontend function) - no need for any event.
Or do the same with an event (and further script in the backend) for the frontend (e.g. header) - but that requires that you have visitors ..

We do such similiar at some clients with data from external sources to update the product (stock, etc.).
Mostly via frontend functions (they can do the same as evey backend script).
How do you call an admin side script via webhost cron when admin scripts require username / login?
Do you have this working? If so what is the mechanism you use to bypass the username/login requirement?

Thank you,
Mike
By building an API: viewtopic.php?f=202&t=220903#p805005 .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Cue4cheap » Thu Jan 13, 2022 10:21 am

Funny, I just realized I tried that extension on my current 2.3.0.2 store and it didn't work for me so I used the https://github.com/iSenseLabs/oc_cli one.
I'll give it a shout on 3.0.3.8 once duplicated.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by OSWorX » Thu Jan 13, 2022 6:01 pm

Cue4cheap wrote:
Thu Jan 13, 2022 7:35 am
How do you call an admin side script via webhost cron when admin scripts require username / login?
With the code changes of 3.x we do such always via frontend scripts.
As written, they can have functionalities like backend scripts (only a few php code lines).
Therefore no complicated calls for API, access, user, etc. is needed.
Only a security phrase/key - which is defined in the backend - has to be submitted together.

Each package consists of 2 parts:
1. backend
2. frontend

All in all 5 (small) scripts:
1-3: backend > controller, language, view
4 & 5: frontend > controller, model

Easy to update, easy to maintain.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Cue4cheap » Fri Jan 14, 2022 7:31 am

OSWorX wrote:
Thu Jan 13, 2022 6:01 pm
Cue4cheap wrote:
Thu Jan 13, 2022 7:35 am
How do you call an admin side script via webhost cron when admin scripts require username / login?
With the code changes of 3.x we do such always via frontend scripts.
As written, they can have functionalities like backend scripts (only a few php code lines).
Therefore no complicated calls for API, access, user, etc. is needed.
Only a security phrase/key - which is defined in the backend - has to be submitted together.

Each package consists of 2 parts:
1. backend
2. frontend

All in all 5 (small) scripts:
1-3: backend > controller, language, view
4 & 5: frontend > controller, model

Easy to update, easy to maintain.
Could you elaborate a little?
I have one main script that does inventory download and updates the levels. I am pretty leery of allowing it on the catalog side.
Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by OSWorX » Fri Jan 14, 2022 3:58 pm

Cue4cheap wrote:
Fri Jan 14, 2022 7:31 am
I have one main script that does inventory download and updates the levels. I am pretty leery of allowing it on the catalog side.
Why leery?
You call the frontend script with the key you define in the backend - without, no further operations are done (the script stops).
That way, nobody can do nothing if that key is not send (included in the cronjob call).

Basically the same way as you would call any backend script (until OC 3.x) or calling any existing (or not existing) API in 3.x which needs the definded and existing API user credentials, session etc.
Only simplier - but safe the same way.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Cue4cheap » Sat Jan 15, 2022 10:44 am

OSWorX wrote:
Fri Jan 14, 2022 3:58 pm
Cue4cheap wrote:
Fri Jan 14, 2022 7:31 am
I have one main script that does inventory download and updates the levels. I am pretty leery of allowing it on the catalog side.
Why leery?
You call the frontend script with the key you define in the backend - without, no further operations are done (the script stops).
That way, nobody can do nothing if that key is not send (included in the cronjob call).

Basically the same way as you would call any backend script (until OC 3.x) or calling any existing (or not existing) API in 3.x which needs the definded and existing API user credentials, session etc.
Only simplier - but safe the same way.
Two reasons... one I don't know the method you reference to pass/verify the key and two I don't like anything dealing with database updates open to the general public.
I'll see if I can find an example of passing/verifying a key.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Mon Jan 17, 2022 1:48 am

Cue4cheap wrote:
Sat Jan 15, 2022 10:44 am
OSWorX wrote:
Fri Jan 14, 2022 3:58 pm
Cue4cheap wrote:
Fri Jan 14, 2022 7:31 am
I have one main script that does inventory download and updates the levels. I am pretty leery of allowing it on the catalog side.
Why leery?
You call the frontend script with the key you define in the backend - without, no further operations are done (the script stops).
That way, nobody can do nothing if that key is not send (included in the cronjob call).

Basically the same way as you would call any backend script (until OC 3.x) or calling any existing (or not existing) API in 3.x which needs the definded and existing API user credentials, session etc.
Only simplier - but safe the same way.
Two reasons... one I don't know the method you reference to pass/verify the key and two I don't like anything dealing with database updates open to the general public.
I'll see if I can find an example of passing/verifying a key.
Mike
The post I referred on my previous reply demonstrates how to obtain an API key from Opencart dynamically.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: SohBH and 268 guests