Jump to content

[RESOLVED]ObjectModel load a class instead of an id


Mehdib92

Recommended Posts

Hi,

 

In my module (in development), when I'm on the form to add a new item, I have the error

 

Notice: Object of class MyClass could not be converted to int in /Users/Mehdi/Sites/mysite/classes/ObjectModel.php on line 197
Notice: Object of class MyClass could not be converted to int in /Users/Mehdi/Sites/mysite/classes/ObjectModel.php on line 206

 

I guess those lines are use to create a cache file and it loads the whole class instead of the id.

 

I don't see how to send the id instead of the whole class...

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

It seems to be resolved...

 

I looked in the AdminCategoryController and I added this line

$this->explicitSelect = true;

 

in the construct of my admin controller and it works...

 

The only thing is that I don't know what this declaration does...

Link to comment
Share on other sites

PrestaShop expects that your object will have a unique integer identifier that defines it from other objects of its type. The internals try to cache the object itself so it doesn't have to spend resources in rebuilding an existing object. With nothing else to go on, maybe using a small random number as the $id in your constructor...

 

Posting your MyClass::__construct() method could help in understanding what's going on...

 

EDIT: The explicitSelect flag limits the amount of data returned by the AdminController::getList(). See line 193 and 2070 of AdminController (PS v1.5.2) for the nitty-gritty details.

Edited by Terragg (see edit history)
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...