Sonata Admin - list of orders by calculated value

Is there a way to have a column in the list of sonata administrators that uses the computed value as a sort with

Something like this: (this does NOT work)

    $mapper->add('stock', null, [
        'sortable' => '(stock.real - stock.inCustomerOrder)',
    ]);
+6
source share
2 answers

Since 2 values ​​come from the same table, how about adding a real column? (and with the Doctrine listener you can keep synchronization when the entity has changed).

Or you can override the query created by Sonata from the documentation here: https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#customizing-the-query-used-to-generate-the -list

0

, / .

0

All Articles