[TYPO3-mvc] Sort query results by a sub-model property

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Fri Jan 28 11:58:58 CET 2011


Hello folks!

trying to sort a query result by the
date property of sub models seems to fail.

There is a relation between two tables
'project' and 'product'. One project can
have many products. Every product has a
property date.

What I want, is to get all projects
ordered by their newest/oldest product.

That means, if I add a new product to
a project, this project should get listed first.

If, on the next day, I'd add a new product
to another project, this project should get
listed first, and the other project shows on the 2nd.

I tried this in the project repository:
$query->setOrderings(array('products.date' => 
Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING));

It kinda seems to work, but it doesn't really
take all products of a project into account.
(It seems it used only the first created product
of each project and used that for ordering.)

I'm not sure if this can be solved easily,
maybe someone of you got an idea about it.

Thanks a lot in advance, I appreciate your help!

Best regards,
Thomas


More information about the TYPO3-project-typo3v4mvc mailing list