DataObject Listing


#1

Hi,
I’m migrating to pimcore 5. Pimcore version 5.0.1.
Using https://pimcore.com/docs/5.0.x/Development_Documentation/Objects/Working_with_PHP_API.html#page_Object-Listings

I want to list my Website Object
$WebsiteObject = new \Pimcore\Model\DataObject\Website\Listing();

I get the following errors:

Class ‘Pimcore\Model\DataObject\Website\Listing’ not found

Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class “Listing” from namespace “Pimcore\Model\DataObject\Website”. …

What is the problem?
Any help please.


#2

Is the name of your DataObject Class really website? Or what are you trying to achieve?

If this is indeed the name of your DataObject, than just try resaving the object in the Object Class editor - just open the class and hit the save button.

Cheers, Igor


#3

Yes, the DataObject class is Website and I’m trying to list the Object data.
I saved the object in the Object class editor and I got the following error:
error

And there is no error message on var/logs/pimcore/debug.log

!?


#4

I tried to do exactly the same thing you are doing and it worked without problems.
Try opening your browser developer tools, then try saving and checking what comes back in the response. Hopefully you will see a more informative Exception message there.

Cheers, Igor


#5

I found the following response

{
“success”:false,
“message”:“An exception occurred while executing \u0027ALTER TABLE object_query_7 CHANGE COLUMN MainLanguage MainLanguage varchar NULL;\u0027:\n\nSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \u0027NULL\u0027 at line 1”
}


#6

var/logs/pimcore/debug.log is the wrong place to log anyway, try to look inside var/logs/dev.log


#7

Try posting your Website DataObject class config in here (screenshot). Something in there seems to be fishy.
Have you maybe converted one of the fields to another type?

Cheers, Igor


#8

That’s right!
I got the following error in var/logs/dev.log:

pimcore.ERROR: An exception occurred while executing ‘ALTER TABLE object_query_7 CHANGE COLUMN MainLanguage MainLanguage varchar NULL;’: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘NULL’ at line 1 [] []


#9

I have’t convert any filed on Website Object.


#10

Testing to call another DataObject (Organisation) \Pimcore\Model\DataObject\Organisation\Listing();
but I get the following error:

Call to undefined function Pimcore\Model\DataObject\Organisation\Listing()

:pensive: !?


#11

Does this file exist var/classes/DataObject/Organisation/Listing.php?

Cheers, Igor


#12

No! var/classes/DataObject/Organisation/Listing.php does’t exist!

I can find it on var/classes/__please_delete_Object/Organisation/Listing.php
!?


#13

OK. You need to resave all DataObject classes and the problem should be resolved. Can you please also show us the config of your MainLanguage field in the Website class?

Cheers, Igor


#14

I still get the error Class cannot be saved. see debug.log when I try to resave the Website and some other classes.
error
But the rest of classes can be resaved without any problem.

MainLanguage field:


#15

Organisation DataObject class resaved without any problem and var/classes/DataObject/Organisation/Listing.php exist.

but I still get:

Call to undefined function Pimcore\Model\DataObject\Organisation\Listing()
"Attempted to call function “Listing” from namespace “Pimcore\Model\DataObject\Organisation”

when i call \Pimcore\Model\DataObject\Organisation\Listing();


#16

have a look inside your definition json files. Guess the problem comes from select fields. Pimcore changed something there and it seems like you are running into that issue. here is the according PR https://github.com/pimcore/pimcore/pull/2086, you can also find the initial commit for that.


#17

pimcore/tests/_support/Resources/objects/class-import.json on my project with Pimcore 5.0.1 so I can see that the new changes on https://github.com/pimcore/pimcore/pull/2086/files doesn’t exist.

I tried to run with 5.0.2 version https://github.com/pimcore/pimcore/blob/v5.0.2/pimcore/tests/_support/Resources/objects/class-import.json
which contains the changes, but it’s not working and I get the same error message.

What Shall I do? I really need to continue with the migration and get my application to work with Pimcore 5.


#18

I still have the same problem :pensive:
!?


#19

hey @m.aliaa,

maybe your php version is 5.6 and should be 7?


#20

Hi @elhenro :slight_smile:
Thanks for the reply!
I’m running PHP 7.1 version (Pimcore 4 and 5).