o0ozinkyo0o Posted June 17, 2014 Share Posted June 17, 2014 Hi all, I have a module with a class inside. I put it in classes folder (./modules/my_module/classes/MyClass.php) Now i want to call to this class at other Class in Core such as Customer.php (root/classes/Customer.php). Example: At function add() in Customer.php. I insert 1 line: MyClass::myfuction(); But it's not work. Anybody help me? Thank you. Link to comment Share on other sites More sharing options...
bellini13 Posted June 17, 2014 Share Posted June 17, 2014 the module class you created is not autoloaded, so you cannot use it without including/requiring the class. you would want to override the Customer class, and add something like the following require_once(_PATH_TO_STORE_'/modules/my_module/classes/MyClass.php'); but really you should not touch the Customer class, but instead use hooks in your module "actionObjectCustomerAddBefore" or "actionObjectCustomerAddAfter" This way you avoid touching Core classes that will break during upgrades, and instead keep it modular so you just re-install the module after an upgrade. The 2 hooks above will allow you to react to a new Customer being created, you can choose to do something before or after the Customer record being created. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now