Jump to content

New class problem in prestashop 1.4


PresaExpert

Recommended Posts

Hello All,
I have added a new class to classes folder. File name is Postal.php and class is PostalCore which is extended from ObjectModel . This class is working fine at admin side, but when i use it at front end like

PostalCore::checkPostalAvailability($postcode)



This code is from authcontroller.
Then it gives me the message "Fatal error" . Note that this error occurs when i include class at just above it like

include './classes/Postal.php';



If i dont include the class like above then i get php error

"Fatal error: Class 'PostalCore' not found in H:\wamp\www\freshdirect\controllers\AuthController.php on line 65" .

I dont understand what is the issue.
Any help will be appreciated.

Thank you

Link to comment
Share on other sites

  • 1 month later...

With the autoloader you don't have to specifically include the class at all, plus you can also just add your class to the overrides/classes directory directly (i.e. you don't have to create a "Core" version unless you absolutely need it to be overridden like the core classes are).

e.g. just create the file /overrides/classes/Postal.php

class Postal extends ObjectModel
{

 .......

}



And just use it without any includes etc.

If you feel that being able to override the class later would be useful, then you can create the following in /classes:

class PostalCore extends ObjectModel
{

 .......

}



But again, you should never need to use an "include" or "include_once" as the autoloader will find and include it for you :)

Paul

Link to comment
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
×
×
  • Create New...