sulu CMS管理界面不显示数据



我正在尝试从控制器显示列表,所有的路由都在加载,但数据没有显示


#[Route(path: '/admin/api/products', methods: ['GET'], name: 'app.get_products')]
public function index(ManagerRegistry $doctrine): Response
{
$products = $doctrine->getRepository(Product::class)->findAll();   
if (!$products) {
return $this->json('No product found');
}
$data = [
'_embedded' => [
'products' => $products
]
];

return $this->json($data);
}

输入图片描述

<?xml version="1.0" ?>
<list xmlns="http://schemas.sulu.io/list-builder/list">
<key>products</key>
<properties>
<property name="id" visibility="no" translation="sulu_admin.id">
<field-name>id</field-name>
<entity-name>AppEntityProduct</entity-name>
</property>
<property name="Product" visibility="always" searchability="yes" type="string">
<field-name>Product</field-name>
<entity-name>AppEntityProduct</entity-name>
</property>

<property name="item_number" visibility="always" type="string">
<field-name>ItemNumber</field-name>
<entity-name>AppEntityProduct</entity-name>
</property>
<property name="quantity" visibility="always" type="integer">
<field-name>quantity</field-name>
<entity-name>AppEntityProduct</entity-name>
</property>
</properties>
</list>

我尝试使用DoctrineRepresentational工厂,但显示未定义。

我错过了什么吗?

您可能想要检查Sulu Workshop存储库并逐步完成不同的Pull Requests。这在开发我的第一个自定义实体时帮助了我:https://github.com/sulu/sulu-workshop/pulls

例如,Sulu人使用自定义的DoctrineListRepresentationFactory类,它通过DoctrineListBuilder返回PaginatedRepresentation。我假设你的代码不工作,因为JSON响应不匹配Sulu Admin所期望的。

最新更新