Jump to content

JEEGuy

Recommended Posts

Hi,

 

I would like to use some functionality of the core class Customer.php (for example the 'customerExists' function).

 

Now when i include the Customer.php inside my class it gets found correctly but the following error gets thrown:

 

Class 'ObjectModel' not found in C:\xampp\htdocs\prestashop\classes\Customer.php on line 29

 

Yet any suggestions how to solve this? (ANYTHING could help after hours of reading & trying)

 

I already found a post to the error:

 

http://www.prestasho...__fromsearch__1

 

According to the post i tried not to include the Customer.php inside my class (located inside the modules folder) but then the Customer.php will not be found. I as well tried to place my class inside the /override/classes folder made it extend from ObjectModel which has thrown basicially the same error.

 

Any suggestions how i can use PrestaShop core classes from within own PHP Scripts/ Classes (located in the modules folder)?

 

Thank you took the time to read this!

Regards

Jan

 

P.s. Background Information: I implemented a third party authorization service (Switch AAI) to authenticate students from Switzerland, which are not yet known to the PrestaShop DB. After successfull authentication id like to use PrestaShop's existing code located in the core classes to add this user to the database (register it) and load it to the context so it's logged in. Thatfore i need the Customer.php class with its functions add(), cleanGroups(), addGroups(..), updateContext(...).

Link to comment
Share on other sites

Is your module ran within prestashop or are you running it outside - e.g calling the file directly in your browser?

 

I ask because Prestashop handles all the loading of classes. Since you're having to include the Customers class directly leads me to believe you are not running from within prestashop.

 

If that is the case then you should include the prestashop config file -

 

include(dirname(__FILE__).'/../../config/config.inc.php');

 

You may need to update this path.

 

This should fix your issue.

Edited by damonsk (see edit history)
Link to comment
Share on other sites

Very many thanks for your reply. Indeed my Script gets called by a redirect from the third party authentication service. I will try your solution tomorrow and post about the success. Again many thanks for the fast reply!

 

Regards

Jan

Link to comment
Share on other sites

Hi,

 

I could not include the file with:

 

include(dirname(__FILE__).'/../../config/config.inc.php');

 

(which should work in general as faar as i have seen after google about it).

 

I instead included it this way:

 

include('../..../../../../config/config.inc.php');

 

Now my errors dont apear anymore but i always get redirected to the index page of PrestaShop...

I will have to further investigate the situation, especially the newly included config file.

 

Many thanks for your help!

 

Regards

Jan

 

P.s. if you have a cloue about the redirect to the index page & why it happens i would appreciate any help :)

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...