Q: Symfony2 - SonataAdmin Bundle Hi? I'm struggling with SonataAdmin Bundle.
I'm Tryng to do a FAQ system.
Here is my actual config. With an Question an Category entities:
services:
    sonata.admin.faq_question:
        class: FM\AppBundle\Admin\Faq\Question
        tags:
            - { name: sonata.admin, manager_type: orm, group: "FAQ", label: "Questions" }
        arguments:
            - ~
            - FM\AppBundle\Entity\Faq\Question
            - ~

    sonata.admin.faq_category:
        class: FM\AppBundle\Admin\Faq\Category
        tags:
            - { name: sonata.admin, manager_type: orm, group: "FAQ", label: "Categories" }
        arguments:
            - ~
            - FM\AppBundle\Entity\Faq\Category
            - ~

With this system, I have a two menu (Questions and Categories).
I would like to have just one menu where I see the Questions grouped by Categories.
Do you think it is possible with the default config of Sonata?
Do I need to override the listAction method in the CRUDController.

A: What you need can be resumed in two main things:


*

*Hide the Categories admin from your dashboard

*Override the default query of the Question's List view


For the first (hide Categories), change the following in your service declaration:
sonata.admin.faq_category:
    # ...
    tags:
        - { show_in_dashboard: false, name: sonata.admin, manager_type: orm, group: "FAQ", label: "Categories" }
    # ...

For the last, add the following to your QuestionAdmin class:
/**
 * {@inheritDoc}
 */
public function createQuery($context = 'list')
{
    $query = parent::createQuery($context);

    // Assuming the Question entity has a $categories field+association
    $query
        ->leftJoin($query->getRootAliases()[0].'categories', 'c')
        ->groupBy('c.id')

    return $query;
}

Hope that fits your need.
