Jump to content

Use cronjob with PS Module Front Controller


Recommended Posts

Hello,

I need to use some of the functionality my front controller currently does.

Beginning of my controller is:

Quote

class CustomerDataTradeDiscountsModuleFrontController extends ModuleFrontController {
    
    public $display_column_left = false;
    public $display_column_right = false;

is there any way I could use it's functionality with cronjob?

I was trying to add code after class ending, with

Quote

$tradeDiscounts = new CustomerDataTradeDiscountsModuleFrontController();

however it says "the module name is invalid".

I could just copy the functions and strip it out of it's object functionality, however is there a proper way the front controller could be instanced?

I would greatly appreciate any help.

Kind regards

Share this post


Link to post
Share on other sites

Hello:

This is a module controller. Module controller belongs to a module, a need it to work. If you want to instance a module controller class from a cron job file your need to include at least the main module file (where the module controller class belongs) in order that Prestashop can find the related module class.

Regards

  • Thanks 1

Share this post


Link to post
Share on other sites

You are absolutely correct. I've managed to solve it yesterday exactly the way you mentioned.

I moved the methods to the class (which should have them anyway, controller should just use them) and I instanced the main module class.

Quote

 $tradeDiscount = new customerdata();
 $tradeDiscount->assignCustomerToTradeGroups();

and everything works like a charm.

Thank you so much.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More