1

I have a table represented in backend with two renderd fields, but when I try to make a csv export from this grid, those two fields are not included.

So I tried to make a join from the initial collection but I would have to make a join with a query / select like this:

SELECT main_table.*, art.artworks_uploaded
FROM mage_artist_details AS main_table
LEFT JOIN (
SELECT artist_id, COUNT(*) AS artworks_uploaded
FROM mage_art_works
GROUP BY artist_id
) AS art ON main_table.user_id = art.artist_id

Any ideeas of how can I obtain this? If I try and use directly this query for my collection, I lose pagination in grid.

If I try and replace a table with a query in the next line I get errors:

$collection->getSelect()->join(array('art' => 'mage_art_works'),'main_table.user_id = art.artist_id',array('artworks_uploaded' => 'COUNT(*)'))
Dan Ovidiu Boncut
  • 3,083
  • 4
  • 25
  • 45
  • 1
    Try to google 'Zend nested select' http://stackoverflow.com/questions/19727859/how-to-build-nested-select-on-zend-db – zhartaunik Apr 06 '15 at 09:36

0 Answers0