Sonata管理员与太多条目形成映射器一对多关系

时间:2016-07-04 16:18:12

标签: types model sonata-admin sonata

我的奏鸣曲存在性能问题。

我构建了一个具有一对多关系的表单,在几个产品的操作之间运行良好,在开发环境中一切都很好,但在生产中,我有250000个要管理的产品,这使得查询非常慢...... 我有一个ajax查询来根据产品的制造商替换我的选择器的内容,但是第一次调用(所有CRUD逻辑的参数)太长了......

这是我的表单映射器

->add( 'operationhasproducts', 'sonata_type_model',
        array(
             'class' => 'MyBundle\Entity\Operationhasproducts',
             'query' => $this->modelManager->createQuery('MyBundle\Entity\Product'),
             'multiple' => true,
             'by_reference' => false,
             'btn_add' => false,
             'required' => false
       )
)

如何在加载页面时不加载250000产品的情况下保留逻辑

我尝试将'query'=> $this->modelManager->createQuery('MyBundle\Entity\Product')->setMaxResults(10),表单显示但是然后crud逻辑不再有效,我有数据转换错误

Symfony\Component\Validator\ConstraintViolation

Object(Symfony\Component\Form\Form).children[operationhasproducts] = [0 => 2739, 1 => 29217]

Caused by:
Symfony\Component\Form\Exception\TransformationFailedException

Unable to reverse value for property path "operationhasproducts": Could not find all matching choices for the given values

Caused by:
Symfony\Component\Form\Exception\TransformationFailedException

Could not find all matching choices for the given values

欢迎任何帮助

0 个答案:

没有答案
相关问题